ASP Regex Allow spaces

This is Classic ASP question but I know many of your brilliant minds probably can answer this for me.

I have a RegEX:

'validation allows only good characters
function valGoodChars(input)
good_chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_."
valGoodChars = true
for i = 1 to len(input)
c = mid(input, i, 1)
if (InStr(good_chars, c) = 0) then
valGoodChars = false
exit function
end if
end function

Works good but I want the ability to ALLOW SPACES between words.

How in this pattern can I allow spaces?

good_chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_."

and if easy to do, put a limit to the number of characters it will accept. It’s easy to to that with a len function but thought I would ask!

Thank you

so, for starters, this isnt a regex.

Its a mechanical equivalent, perhaps.

What happens if you… put a space into the good characters string?

1 Like

There you go! That was too simple. I was trying to make it more difficult than it was, thanks.

Yes, because I was trying some regex characters in it and didn’t work. So then a regex has those character in it. Doesn’t some regex have .pattern = “character etc” in it?

Probably better than nothing. I guess I couldn’t find any real regex’s.

Thanks for your help, its appreciated.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.