I’m trying to parse some bbc code like this:
[item=1]a[/item]
[item=2]b[/item]
[item=3]c[/item]
I’m able to get the first item, but i can’t get the second and third. I’m trying to grab each item, and convert it to a link. Here’s the result i’m going for:
<a href="#1">a</a>
<a href="#2">b</a>
<a href="#3">c</a>
Here’s what I’m doing:
/\[item=(\d+)\](.*?)\[\/item\]/
Which gives me:
["[item=1]a[/item]", "1", "a"]
What am I doing wrong?
Try adding the “global” option to your expression
That should work on most regex implementations, but when your provide which one you are using (or at least what language you are programming in), I can check into that.
On a further note: Add the case-insensitive option also, so
ITEMwill also be matched.On a further futher note: Here is a working example