Developing a shorthand parser as part of a client's application. I want to set up a shorthand for creating links similar to mediawiki.
I.E.: [[link_location|link_title]]
eventually becomes <a href="link_location">link_title</a>
What I need to do is extract the string from between the brackets so I can process it; there's a bunch of validation and keyword conversion to do before it can go into a link. I'm pretty new to preg_match
- I can match the bracketed expression with /\[\[(.*?)\]\]/
, but I have no idea how to extract the string from the middle. Can anyone tell me what I'm missing? Or, if I'm going about this all wrong, have mercy and point me in the right direction?
Thanks!
EDIT: I should have clarified: I need to extract the string and process it, so preg_replace
ing it directly into a link won't work in this case.