我有一个很大的正则表达式,我已经打开了IgnorePatternWhitespace,所以我可以让它更具可读性.我的问题是我想匹配一个文字空格字符.最好的方法是什么?
一个例子:
Regex myRegex = new Regex(@"
(?> <table[^>]*> ) # Find a table
(?> .*?<tr> ) # Find the first row
(?> .*?<th> ) # Find the first header column
My phrase # Look for our key phrase
etc.
", RegexOptions.IgnorePatternWhitespace);
Run Code Online (Sandbox Code Playgroud)
在上面的例子中,"我的短语"应该包含一个空格.