Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JQuery Regular expression to accept alphanumeric characters and ' , -

I'm trying to figure out how to get my regular expression to accept certain special characters: ', , and - along with alphanumeric characters. I've had a stab at it but to no avail, and I'm quite new to regex, can anyone help?

Here was my attempt which, surprisingly, didn't work...

/^\d+/,\'\-\$/i
like image 849
pam Avatar asked Jun 13 '26 15:06

pam


1 Answers

Something like this?

/[0-9a-zA-Z',-]+/

if it has to be a full string, you can use

/^[0-9a-zA-Z',-]+$/
like image 192
simon Avatar answered Jun 15 '26 05:06

simon



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!