我使用下面的正则表达式从VisualStudio中搜索sql脚本文件,在文件对话框中查找文本:
from\s+(Table123|\[Table123\])\s*
输出:
FROM [Table123] [i]
FROM Table123 I
FROM Table123Extended t1
FROM Table123";
How can I modify my regular expression to eliminate third result
1. FROM [Table123] [i] (correct)
2. FROM Table123 I (correct)
3. FROM Table123Extended t1 (incorrect)
4. FROM Table123"; (correct)
答案 0 :(得分:1)
这\ S +(Table123 | [Table123])(\ S + |&#34)
答案 1 :(得分:0)
您希望确保匹配以双引号或空格结尾,因此,您应将[\s"]
替换为from\s+(Table123|\[Table123\])[\s"]
并使用
[\s"]
<ol>
<li>one</li>
<li>two<li>
</ol>
是*字符类*,它匹配类,hete,空格或双引号中定义的任何单个字符。