Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 11th, 2012  |  syntax: None  |  size: 0.33 KB  |  hits: 8  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. capturing group in regex
  2. /(?:madhur)?/
  3.        
  4. /(madhur)?/
  5.        
  6. "madhur".replace(/(madhur)?/, "$1 ahuja");   // returns "madhur ahuja"
  7. "madhur".replace(/(?:madhur)?/, "$1 ahuja"); // returns "$1 ahuja"
  8.        
  9. /(mad)hur/.exec("madhur");   // returns an array ["madhur", "mad"]
  10. /(?:mad)hur/.exec("madhur"); // returns an array ["madhur"]