I can't get the results I'm looking for with regex and nested items
I'm working on some regex right now to isolate bracketed code such as this...
Regex: /\[(.*?)\]/
String: "<strong>[name]</strong>
<a href="http://www.example.com/place/[id]/">For more info...</a>"
Matched Fields: name, id
I'm looking to make this a bit more advanced. What I'm looking to do...
String: "[if:name <strong>[name]</strong>]
<a href="http://www.example.com/place/[id]/">For more info...</a>"
Matched Fields: if:name <strong>[name]</strong>, id
The problem is, I can't figure out any regex that'll work for this. I'm
pretty sure I've killed the better half of my day, and I feel like I'm
pretty close.
Here's what I've got at the moment that isn't doing what I want...
/\[([^\]]+)\]/
Anyone have any ideas?
No comments:
Post a Comment