我正在使用正則表達式在另一個字符串中搜索字符串模式的vba宏。如何在正則表達式模式中包含變量
正則表達式模式包括一個字符串(下面的代碼中的APR24),它會發生變化。我需要知道如何在模式中包含一個變量。請任何人都幫忙。
我的代碼如下
Public Function Regexsrch(ByVal str2bsrchd As String, ByVal str2srch As String) As Boolean
Dim Regex As New VBScript_RegExp_55.RegExp
Dim matches, s
Regex.Pattern = "(\.|\s)APR24(,|\s|\()"
Regex.IgnoreCase = True
If Regex.Test(str2bsrchd) Then
Regexsrch = True
Else
Regexsrch = False
End If
End Function
見隨訪上面 –
@Downvoter的帖子:我不介意downvote,但至少有正派留下來評論你爲什麼感到需要downvote?或者要求太多? –