user3142386
user3142386

Reputation: 181

Regex for excluding apostrophe(') character

I need a regex that will include all the alphabets, numbers and even all special characters except apostrophe(').

The below regular expression will work only for numbers and alphabets.

/^[a-z A-Z 0-9 ]*$/

But I need a regular expression which includes all the special characters except apostrophe (').

Upvotes: 1

Views: 9159

Answers (2)

Trott
Trott

Reputation: 70075

The regular expression for "any character other than an apostrophe" would be: [^'].

So a regular expression that will match a string as long as it does not have an apostrophe would be: /^[^']*$/

Upvotes: 6

Rahul Tripathi
Rahul Tripathi

Reputation: 172418

You can try to use this regex:

[^']

This Regex will match every character except apostrophe

Upvotes: 6

Related Questions