Negation of regular expression

wmgeiger101x

I have this regular expression:

var regex = /^[-.:_A-Za-z0-9]*/;

But I need to test a string to see if it has any characters that do not match that expression.

I have tried

var regex =/^[^-.:_A-Za-z0-9]*$/;

But that did not catch the characters that I am looking for.

Basically, I need a regular expression that I can use in javascript to find any character that is not - . : . A-Z a-z or 0-9 in a javascript string variable.

thisShouldPass

thisShou[][]ldFail

Alex Booker

I suspect you want to remove the anchors and the *:

var regex =/[^-.:_A-Za-z0-9]/;

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related