I have string in following format
some other string @[Foo Foo](contact:2) some other string @[Bar Bar](contact:1) still some other string
now I want this string into
some other string <a href="someurl/2">Foo Foo</a> some other string <a href="someurl/1">Bar Bar</a> still some other string
so basically need to replace the @[Some name](contact:id)to url using groovy &using reg ex what is the efficient way to do it
You can use the Groovy
replaceAllString method with a grouping regular expression:/@\[([^]]*)]\(contact:(\d+)\)/=~@[Foo Foo](contact:2)/begins a regular expression pattern@matches@\[matches[(begins the text group[^]]*matchesFoo Foo)ends the text group]matches]\(contact:matches(contact:(begins the contact group\d+matches2)ends the contact group\)matches)/ends the regular expression pattern