Reputation: 774
Trying to find instances of "N/A" in markup and swap out with something else,
var $reg = new RegExp('[Nn]/[Aa]');
other variations were:
/[Nn]/[Aa]/
'^[Nn]/[Aa]'
Upvotes: -1
Views: 59
Reputation: 253496
I'd suggest:
stringToSearchIn.replace(/(N\/A)/gi,'words to replace with');
\/
escapes the slash, as the /
character delimits the regex string, andgi
at the end:
g
is for a global search, so it doesn't stop after the first match, andi
is case-insensitive (so it'll match n
and N
, a
and A
.Upvotes: 2