0

Hello,
I want expression for not acception string with specials characters.
So I was with expression

/^[ A-Za-z0-9_@.#&,()-]*$/

But it is accepting only special chars also.
How can I restrict it for not acceptiong only special chars?
like my string should contain atleast one character.

3
Contributors
4
Replies
16
Views
2 Years
Discussion Span
Last Post by Taywin
0

my string should contain atleast one character.

Use + instead of *

You need to escape the dot too:

/^[ A-Za-z0-9_@\.#&,()-]+$/
0

Hello
Thanks.
I had already tried with + too.
But it was not working.
Used expression /^[ A-Za-z0-9_@\.#&,()-]+$/ too.
But it not working.
It is accepting string &&&&&

0

/^[a-zA-Z]+[ A-Za-z0-9_@\.#\n&,()-]*$/ worked for me.
Thanks

0

Don't think it will work for any string starting with a number. It will work with string starting with a letter (and followed any other character listed in the regex or none). What is the purpose of this regex?

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.