C
CJM
I'm trying to validate and input field that allows an integer or a single
'*' character using regular expressions, but I'm not getting the results I'm
expecting.
I'm trying to match against the pattern "[^0-9]*|[^\*]", which I hoped would
translate to 'match against groups of the numbers (0-9) or against a single
*'. However, it's matching against character 1 for each of the examples
below when Global = False. When Global = True, it matches against character
2 for S4/S5, and against one after the last character for S1-S3.
I'm sure this is a simple one for the RegExp experts amongst us. Any
thoughts?
Thansk
CJM
'Code Snippet
Dim oRegExp, oExpMatch, s1, s2, s3, s4, s5
Set oRegExp = new RegExp
With oRegExp
s1 = "12345" 'valid
s2 = "*" 'valid
s3 = "12*" 'not valid
s4 = "ABC" 'not valid
s5 = "**" 'not valid
.Global = True
.Pattern = "[^0-9]*|[^\*]"
Set oExpMatch = oRegExp.Execute(s1)
Set oExpMatch = oRegExp.Execute(s2)
Set oExpMatch = oRegExp.Execute(s3)
Set oExpMatch = oRegExp.Execute(s4)
Set oExpMatch = oRegExp.Execute(s5)
Response.Write "Match " & oExpMatch.Count
End With
Set oExpMatch = nothing
Set oRegExp = nothing
'*' character using regular expressions, but I'm not getting the results I'm
expecting.
I'm trying to match against the pattern "[^0-9]*|[^\*]", which I hoped would
translate to 'match against groups of the numbers (0-9) or against a single
*'. However, it's matching against character 1 for each of the examples
below when Global = False. When Global = True, it matches against character
2 for S4/S5, and against one after the last character for S1-S3.
I'm sure this is a simple one for the RegExp experts amongst us. Any
thoughts?
Thansk
CJM
'Code Snippet
Dim oRegExp, oExpMatch, s1, s2, s3, s4, s5
Set oRegExp = new RegExp
With oRegExp
s1 = "12345" 'valid
s2 = "*" 'valid
s3 = "12*" 'not valid
s4 = "ABC" 'not valid
s5 = "**" 'not valid
.Global = True
.Pattern = "[^0-9]*|[^\*]"
Set oExpMatch = oRegExp.Execute(s1)
Set oExpMatch = oRegExp.Execute(s2)
Set oExpMatch = oRegExp.Execute(s3)
Set oExpMatch = oRegExp.Execute(s4)
Set oExpMatch = oRegExp.Execute(s5)
Response.Write "Match " & oExpMatch.Count
End With
Set oExpMatch = nothing
Set oRegExp = nothing