문제

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, "")
도움이 되었습니까?

해결책

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

다른 팁

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top