can u write me how to take string and remove all letter and signs and leave only 7 digit? example: if I got abc1234567-d or a12c3f-45kj6%7ud-
then return 1234567 Thanks
Join Stack Overflow to learn, share knowledge, and build your career.
can u write me how to take string and remove all letter and signs and leave only 7 digit? example: if I got abc1234567-d or a12c3f-45kj6%7ud-
then return 1234567 Thanks
This removes all but 0-9
, .
, and ,
as they are valid parts of numbers.
This is known as regular expressions. See VBScript's Help.
Set re = New RegExp
re.Pattern = "[^0-9\.,]"
re.Global = True
re.IgnoreCase = True
Sortkey = re.Replace(Sortkey, "")
\D
or \D+
would be a more appropriate expression.
– Ansgar Wiechers
Feb 13 '17 at 21:49
Public Function ExtractNumber(Source as string) as string
dim result as string = string.empty
for each c as char in Source
if isnumeric(c) then result &= c
next
return result
end function