I found this regex on a forum:
"/\+?\)\)(=.+?,.+?)?\](.+?)\[\/quote\](?!((.*?)\[\/quote\]))/s"
The regex should be able to extract data from a string. I will give you an example:
<?php
$string = ‘[quote=username]bla bla bla bla[/quote]’;
preg_match("/\+?\)\)(=.+?,.+?)?\](.+?)\[\/quote\](?!((.*?)\[\/quote\]))/s", $string, $match, null, 0);
print_r($match);
… However, nothing is returned to $match. I am guessing that there is something wrong with the regex, since it should return both ‘username’ and ‘bla bla bla bla’.
I am going to use the function for a quote function in a forum.
Thanks in advance,
fischer
I would use something a little easier to read…
Output
See it on IDEone.
I assume your string will contain more than that – hence lazy quantifiers and no beginning and end anchors.
Also, make sure your string is delimited by single (
') or double quotes ("), not backticks. Backticks are syntactic sugar for ashell_exec()call.Update
I’ll try and decipher your original regex for you…