Let’s say I have a string like so:
“Lorem ipsum de color [post]57[/post]
sit amet [post]103[/post] desectator.”
I want to find all occurrences of [post]*[/post] and replace it with the title of the post represented by the number. I’d end up with something like so:
“Lorem ipsum de color Angry Turtle sit
amet Fuzzy Rabit desectator.”
I’m guessing a regex will be needed… looking for what the regex would be and how to use.
The gsub method on String has a handy block variation that works well here:
Your syntax couldn’t be much less regex friendly though. Try not to use brackets and slashes.