Skip to main content
 首页 » 编程设计

C# 正则表达式

2024年01月16日36rubylouvre

你能解释一下这个正则表达式的含义吗?与此表达式匹配的字符串是什么。

Regex(@"/Type\s*/Page[^s]");  

什么是@符号??提前致谢。

Please provide full explaination. What would be the string which matches to this expression.

请您参考如下方法:

@ 符号表示 verbatim string literal :

A verbatim string literal consists of an @ character followed by a double-quote character, zero or more characters, and a closing double-quote character. A simple example is @"hello". In a verbatim string literal, the characters between the delimiters are interpreted verbatim, the only exception being a quote-escape-sequence. In particular, simple escape sequences and hexadecimal and Unicode escape sequences are not processed in verbatim string literals. A verbatim string literal may span multiple lines.

至于正则表达式,它分解如下:

/Type match this string exactly
\s* match any whitespace character zero or more times
/Page match this string exactly
[^s] match any character that isn't "s"