So I have this comment-esk like system I am working on, and apparently I didn't think it all the way through, however I am blocked into my method at this point for the time being and foreseeable future. That said.
I am currently using
$pattern = '/\[@(\w+):(.*)\]/';
$subject = '[@keyword:string]';
preg_match($pattern, $subject, $matches);
To find specific info from a particular pattern type. Which is something to the extent of [@keyword:string]
, and this works great. However in my searches to come up with this method of doing that it failed to dawn on me that the strings I am using this on also contain other stuff, such as a comment. So the over all string would look like '[@keyword:string]
Hello World`
The above bit of code will dump an array for me, first item the actual match I was looking for, the next being the keyword and the next the string. Which is great, as I use this for something else. However. Like I said I never compensated for the <br>Hello World part
so. What I need to do is something very similar to the above. But only leave the <br>Hello World
part as a reusable string as I am intent on rejoining the 2 strings. After my process is done. Except, the process after its done in this case is replacing the pattern I am looking for with a matching User Name, or an Image based on the keyword, which then dispatches a function to find the right name, or create the image tag for the image. Which thats fine I got that part, its just the stripping of the pattern from the string so when I get the name(s) or image back I can rejoin it to the string.
Well hopefully that makes sense.