Regular Expressions and Replace Function
My valid characters for username are letters and numbers only.
so if the username is abc*67% i want to replace the invalid chars with nothiing. so the correct result should be abc67. i get abc67%.
I am able to replace only one invalid character. the others stay as it is . any input?
this is my code:-
username = rtrim(rssqlusername("ag_username"))
'Test the ag_username for valid chars
' Valid Characters Include Letters and Numbers only
set Regexforinvaliddata = New RegExp
Regexforinvaliddata.Pattern ="[^A-Za-z0-9 ]"
set colMatches = Regexforinvaliddata.execute(username)
'Step through our matches
for each Regexforinvaliddata in colmatches
searchchar = Regexforinvaliddata.value
username = replace(username, searchchar, "")
Next
|