0

I have a regex replace running in my javascript that looks likes this,

this.set('activity', activity.replace(/{(object)}(.*?){\/\1}/gi, '<a href="' + object_link + '" class="' + linkClass + '">$2</a>'));
this.set('activity', activity.replace(/{(object)}(.*?){\/\1}/gi, '<a href="' + object_link + '" class="' + linkClass + '">$2</a>'));

The above works great when the strings look something like this,

{blockquote}{object}Joe Bloggs{/object} did something great!{/blockquote}

However if the strings is multi-line, i.e

{blockquote}{object}Joe Bloggs{/object} did something great  
and it broke on to two lines{/blockquote}

I thought I would be able to just add the multiline check in to my regExp, like so,

this.set('activity', activity.replace(/{(object)}(.*?){\/\1}/gmi, '<a href="' + object_link + '" class="' + linkClass + '">$2</a>'));
this.set('activity', activity.replace(/{(object)}(.*?){\/\1}/gmi, '<a href="' + object_link + '" class="' + linkClass + '">$2</a>'));

But it does not parse out the {object} and {blockquotes} as it does for single line of text

Any ideas why?

Legionar
  • 7,472
  • 2
  • 41
  • 70
Udders
  • 6,914
  • 24
  • 102
  • 194

0 Answers0