I need a simple help:
need to match:
[sometext]
[sometext value=1]
[sometext value=1 anothervalue=2]
with php regex and replace with null in entire $content variable
$content = str_replace('/??????/','',$content);
What should I place instead of question marks?
Ps… anybody know a good resource for dummies to learn regex?
The regex that you should use should be something like:
It basically breaks down to:
\[matches the opening square bracket.[^\]]*matches anything until the next closing square bracket.\]matches the ending square bracket.Also, you should use
preg_replace, asstr_replacedoesn’t accept a regex. So you end up with:You can find plenty of info about the regex flavour used in PHP in the PCRE regex syntax page of the PHP doc.