Eric
Eric

Reputation: 10646

Inverse regex javascript

I'm trying to remove everything in a string that does not match 'standard' characters. Heres what I have so far:

var result = myString.replace(/^(?![A-Za-z0-9]+)/g, '');

Which does not work. Can someone point to me what I'm not doing right?

Upvotes: 3

Views: 2792

Answers (1)

Niet the Dark Absol
Niet the Dark Absol

Reputation: 324630

I think you mean this:

var result = myString.replace(/[^a-z0-9]/gi,'');

Upvotes: 7

Related Questions