Forgive me for not being better at regular expressions.
Apologies: example is updated
I am cleaning up some garbage in a phpBB forum with a PHP script. phpBB encodes bbcode with some sort of key, an 8 digit string that appears after a colon. Here is an example:
outer [size=5:24f81ld3]inner text[/size:24f81ld3] outer
I am trying to strip out where the size is one character, not two, so the above would become:
outer inner text outer
But this:
outer [size=100:24f81ld3]inner text[/size:24f81ld3] outer
Would NOT become this:
outer inner text outer
Appreciate any help!
Here's the code
Here are the test use cases:
Here's the output:
Important note: The function does not handle nested
size
tags correctly!If you're interested in regular expressions, this wonderful resource covers them in all details and flavors: http://www.regular-expressions.info/