VBScript.RegExp sẽ bị xóa khỏi Windows: thư viện Pcre2 giải pháp thay thế tối ưu (1 người xem)

Người dùng đang xem chủ đề này

***Cập nhật: sửa lỗi và thêm truy vấn name grouping, với hàm IndexByName trong lớp IRegExp

Ví dụ:
JavaScript:
Sub test1()
  Dim re As IRegExp, m As Object
  Set re = New IRegExp
  re.Pattern = "(?<numbers>123).+?(?<chars>abc).+?(?<sign>@@@)"
  re.GlobalSearch = True
  Set m = re.Execute("123  abc  @@@")
  Debug.Print "          Match count: "; m.count
  Debug.Print "           Match Text: "; m(0)
  Debug.Print "   Match - FirstIndex: "; m(0).FirstIndex
  Debug.Print "    Match - LastIndex: "; m(0).LastIndex
  Debug.Print "          SubMatch[1]: "; m(0).SubMatches(1)
  Debug.Print "SubMatch - FirstIndex: "; m(0).SubMatchFirstIndex(1)
  Debug.Print " SubMatch - LastIndex: "; m(0).SubMatchLastIndex(1)
  Debug.Print "  SubMatch['numbers']: "; m(0).SubMatches(re.IndexByName("numbers"))
End Sub
 
Upvote 0

Bài viết mới nhất

Back
Top Bottom