0

I have two regular expression. How can I convert them into one:

str = str.replace(/(\s\(\d+\)|exception\s*\:*)/gi, "<br /><br />$1");
str = str.replace(/(exception\s+No\.\s*\d\:)/gi,"<br /><br />$1");

I want to convert them into one regular expression. How can i do it?

thanks in advance

Sundar Ban
  • 589
  • 5
  • 16

1 Answers1

0

Probably not an optimized regexp but a very simple solution is to combine your regexps with a |:

str = str.replace(/((?:\s\(\d+\)|exception\s*\:*)|exception\s+No\.\s*\d\:)/gi, "<br /><br />$1");
speakr
  • 4,141
  • 1
  • 22
  • 28