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,254
  • 2
  • 37
  • 67
Udders
  • 6,660
  • 23
  • 98
  • 179

0 Answers0