.NET与PHP正则表达式高级特性解析
1 .NET高级特性
1.1 支持函数
1.1.1 Regex.Unescape
Regex.Unescape 函数接收一个字符串,返回一个经过处理的副本。它会解释特定的正则表达式字符转义序列,并移除其他反斜杠。例如,传入 '\:\-\)' ,会返回 ':-)' 。字符简写也会被解码,如 '\n' 会被替换为换行符, '\u1234' 会被替换为对应的Unicode字符。
1.1.2 Match.Empty
Match.Empty 函数返回一个表示匹配失败的 Match 对象。它可用于初始化一个 Match 对象,后续可能会填充该对象并进行查询。示例代码如下:
Dim SubMatch as Match = Match.Empty 'Initialize, in case it’s not set in the loop below
Dim Line as String
For Each Line in EmailHeaderLines
'If this is the subject, save the match info for later...
Dim ThisMatch as Match = Regex.Match(Line, "^Subject:\s+(.
.NET与PHP正则高级特性对比
超级会员免费看
订阅专栏 解锁全文

被折叠的 条评论
为什么被折叠?



