Skip to main content
Hi,

I am using pattern and matcher to [@name1]. Below is the regex

 

Pattern.compile('\\[\\@([a-z|A-Z|0-9].*?)\\]');

Using the matcher to get the values

String mentionName = pm.group(1);

Everything is works fine if it has only one [@name1] with specified pattern.

If it has more than one like [@name1] [@name2] only one value is returned. is it possible to get more than one value from the group?
3 réponses
  1. 14 juil. 2015, 09:34

    Hi Shingo,

    Thank you. But my problem is I am replacing the [@name] with some HTML and appending it.

     

    fc.CommentBody = fc.CommentBody.replace('[@' + mentionName + ']', '<a href=\'' + repo.getBaseUrl() + '/' + memberC.id + '\'>@' + mentionName + '</a>');

    I need to replace [@name] with a tag even if it has more than one pattern matched value