Question

I would I go about stripping all numbers from a string?

This code below is what I have been trying.

objRegExp.Pattern = "((?![a-zA-Z]).)+"
queryForHTML = objRegExp.Replace(queryForHTML, "")
Was it helpful?

Solution

KISS. You want to find all sequences of one or more digits (to delete them). So the pattern is "\d+". Trying to specify what you don't want to find/delete is errorprone/clumsy/not necessary.

>> Set re = New RegExp
>> re.Pattern = "\d+"
>> re.Global = True
>> WScript.Echo re.Replace("a1b234c", "")
>>
abc
>>

OTHER TIPS

This works in JavaScript /[0-9]/g it will find all occurrences of digits, and your replace will trim those out. /g is for global, I think vbscript has a Global property which you can set

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top