Programming Questions

  • Newest
  • Popular Tags
  • Ask A Question
  • Simple Symbols Regular Expression
    Is this code incorrect ? I coded this for the Simple Symbols challenge. When submitted, the code changes.
    function SimpleSymbols(str) { 
      // code goes here 
      var tmp = str.replace(/[^A-z]/g, ''); 
      var find = str.match(/+[A-z]+/g); // <-- This chars '' are removed when submitted to test 
      if (tmp.length === find.length) { return true; }
      else { return false; } 
    } 
    // keep this function call here 
    SimpleSymbols(readline()); 
    
    jcgomezv00 posted this question on 6/27/18 | javascript, simple, symbols, regular, expression
    Answers
  • +
  • 0
  • -
  • In the second line of the code, the plus signs (+) in the regular expression should be preceded by escape characters (). Without it, the plus sign has a special meaning as part of the regular express, indicating one or more repetitions of the preceding character.
  • +
  • 0
  • -
  •   var tmp = str.replace(/[^A-z]/g, ''); //you have to place a space between  in your code 
      var find = str.match(/+[A-z]+/g); //<-- you need to change this regular expresssion
    
    Log in to write an answer.