I got the following code and I'm trying to make it match on a class instead of on an id:
Html:
[First Title|http://test.com]
Another line
[Second Title|http://test.com]
More text
[Third Title|http://test.com]
Javascript:
var textContainer = document.getElementById("testdiv");
var linkText = textContainer.innerHTML;
var pattern = /\[([^|]+)\|([^>]+.?)[^<]*(<\/a>)\]/g;
var result = linkText.replace(pattern, "$2$1$3");
textContainer.innerHTML = result;
Full example: http://jsfiddle.net/JFC72/17/
How can I make it match on "myclass" instead? Thanks!