regex - Regular Expression using vbscript for two numbers: not valid:"$123456789012" and valid: "12345678912" -
i wanted create regular expression find number 10 or more digits , number should not have $ symbol in front of it.
eg: not valid:$123456789012 , valid: 12345678912.
apart have more validations example finding number pattern: 3digits - 4digits, 3digits - 4digits - 5digits.
but able create pattern unable $<number>, please help.
sorry not mentioning in beginning - using vbscript.
code:
regularexpressionobject.ignorecase = true  regularexpressionobject.global = true  regularexpressionobject.pattern =     "(([0-9]{3}-[0-9]{4})|([0-9]{3}-[0-9]{4}-[0-9]{5})|([0-9]{3}-[0-9]{4}-[0-9]{5}-[0-9]{6})|([0-9]{10}))"     'pattern:ccid or 3(digits)-4(digits), 3(digits)-4(digits)-5(digits), 3(digits)-4(digits)-5(digits)-6(digits), 10digts , above number  set matches = regularexpressionobject.execute(rescomts)     if (matches.count <> 0)    in above code, regular expression pattern 10 digits allowed, wanted ignore 10 digits starting $ symbol
as @sam said, use negative look-behind:
(?<!\$)\b[0-9]{10,}\b   example: http://regex101.com/r/vr3if6
depending on language selected, look-around may not available. example, javascript limits use of (?<!\$) may need write as
[^$]\b[0-9]{10,}\b   example: http://regex101.com/r/oh5ue4
some languages support \d, may make regex cleaner. others don't, , you'll need write [0-9].
edit per @alanmoore's suggestion, extraneous characters may interfere. might able around using \b[^$]\b instead of single \b:
\b[^$]\b[0-9]{10,}\b   example: http://regex101.com/r/ll2bn9
this rid of preceding spaces, non-digit characters, etc.
Comments
Post a Comment