.NET与PHP正则表达式高级特性解析
1..NET高级特性
在.NET中,有一些高级特性值得深入探讨,包括使用正则表达式程序集构建正则表达式库、匹配嵌套结构以及捕获对象的使用。
1.1 正则表达式程序集
.NET允许将Regex对象封装到程序集中,这对于创建正则表达式库非常有用。以下是构建和使用正则表达式库的步骤:
1. 构建正则表达式库 :
Option Explicit On
Option Strict On
Imports System.Text.RegularExpressions
Imports System.Reflection
Module BuildMyLibrary
Sub Main()
Dim RCInfo() as RegexCompilationInfo = {
New RegexCompilationInfo(
"^Subject:\s+(.+)", RegexOptions.IgnoreCase,
"Subject", "jfriedl.Mail", true
),
New RegexCompilationInfo(
"^From:\s+(.+)", RegexOptions.IgnoreCase,
"From", "jfriedl.Mail", true
),