-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRegexCheck.vbs
More file actions
37 lines (34 loc) · 1.3 KB
/
Copy pathRegexCheck.vbs
File metadata and controls
37 lines (34 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
Option Explicit
'--------------------------------------------------------------------------------
' ScriptName : RegexCheck.vbs (was RegexpCheck.vbs)
' Creator : Sungman Han
' Creation Date : 2019-05-28
' Description : Regular expression helpers used to scrub values coming out of SAP
' screens and Excel cells.
'
' Usage : StripPattern("A-123-B", "[^0-9]") -> "123"
' MatchesPattern("A-123-B", "^\d+$") -> False
'
' Note : the original single routine was named like a test but behaved like
' a replace, and it returned Empty instead of "" when the pattern
' consumed the whole input. The two operations are now separate and
' both always return their own type.
'--------------------------------------------------------------------------------
Function StripPattern(vValue, vPattern)
With CreateObject("VBScript.RegExp")
.Global = True
.IgnoreCase = True
.Multiline = True
.Pattern = vPattern
StripPattern = .Replace(vValue & "", "")
End With
End Function
Function MatchesPattern(vValue, vPattern)
With CreateObject("VBScript.RegExp")
.Global = True
.IgnoreCase = True
.Multiline = True
.Pattern = vPattern
MatchesPattern = .Test(vValue & "")
End With
End Function