正则表达式问号的四种用法详解
(编辑:jimmy 日期: 2025/11/3 浏览:3 次 )
原文符号
因为"htmlcode">
string pattern1 = @"a.*c"; // greedy match
Regex regex = new Regex(pattern1);
regex.Match("abcabc"); // return "abcabc"
非贪婪匹配
在满足匹配时,匹配尽可能短的字符串,使用"htmlcode">
string pattern1 = @"a.*"; // non-greedy match
Regex regex = new Regex(pattern1);
regex.Match("abcabc"); // return "abc"
几个常用的非贪婪匹配Pattern
*"htmlcode">
while(<>){
if(/("Fred wants a $1\n" ;
}
}
下一篇:利用正则表达式抓取博客园列表数据