I am trying to create a regular expression that will match the square brackets URL tags as follows: -
[url]some text[/url]
or
[url class="class"]some text[\url]
This is the template that I created.
(\[url.*\])(.*?)(\[\\url\])
It works fine if there is only one tag, if I have two tags in the sentence:
This is a sentence [url]blah[\url] this is another sentence[url]blah[\url]
It has only one match and captures everything between the first opening and the last closing [url] tag. I did some research and added ? to stop his greed and seizure of everything, but he does not work. I also tried using:
[^\[]*
instead
(.*?)
again it doesn't matter.
source share