12-12-2007, 10:38 AM
|
#7 (permalink)
|
|
The Frequenter
Join Date: Dec 2007
Location: Bucharest, Romania
Posts: 438
Thanks: 3
|
One more thing, though. How about recursivity in a regex rule? How does that work? I'm trying to make a simple BB code parser (just playing around), and something doesn't add up. Example:
Code:
/\[(b|i|u)(?:.+?)?\](.+?)\[\/\1\]/
would successfully match:
,
(without the spaces of course), but the following expression...
Code:
[b ]some [i ]text[/i ][/b ]
would leave me with:
That's when recursivity popped in my mind and I did a Google search. But I believe I don't use properly, or the back-references don't remain the same during a recursive operation, because this rule:
Code:
/\[(((b|i|u)(?:.+?)?)|(?R))\](.+?)\[\/\1\]/
, applied on the text introduced at the top, leaves me with:
Spooky 
__________________
I have optimistic thoughts, even though sometimes (if not always) life's a bitch.
|
|
|
|