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, "")
Était-ce utile?

La 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
>>

Autres conseils

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

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top