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.

my string should contain atleast one character.

Use + instead of *

You need to escape the dot too:

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

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

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

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?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.