LoginSignup
1
1

More than 5 years have passed since last update.

VBAで正規表現の関数

Last updated at Posted at 2016-10-21

存在するか

Public Function existRegexp(target, matchPattern, Optional ignoreCase = True) As Boolean 'ignoreCaseは大文字小文字区別するかどうか

    Set regexp = CreateObject("VBScript.RegExp")


    With regexp
        .Pattern = matchPattern
        .ignoreCase = ignoreCase
        .Global = False
    End With

    existRegexp = regexp.test(target)
End Function

正規表現のマッチング取得

Public Function getRegexp(target, matchPattern, Optional ignoreCase = True, Optional global_ = True) 'ignoreCaseは大文字小文字区別するかどうか global_は複数回マッチングするかどうか

    Set regexp = CreateObject("VBScript.RegExp")

    With regexp
        .Pattern = matchPattern
        .ignoreCase = ignoreCase
        .Global = global_
    End With

    Set getRegexp = regexp.Execute(target)
End Function
1
1
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1