-1

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]'
2
  • You just need to escape that forward slash. Turn / into \/ Commented Apr 24, 2012 at 18:20
  • 1
    And how do you apply that regex? What is the actual outcome and the expected outcome? Commented Apr 24, 2012 at 19:10

2 Answers 2

2

I'd suggest:

stringToSearchIn.replace(/(N\/A)/gi,'words to replace with');
  1. \/ escapes the slash, as the / character delimits the regex string, and
  2. the gi at the end:
    • g is for a global search, so it doesn't stop after the first match, and
    • i is case-insensitive (so it'll match n and N, a and A.

JS Fiddle demo

Sign up to request clarification or add additional context in comments.

Comments

0

You could just use this one:

N\/A

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.