Hi all
I suspect the answer to this is simple but for whatever reason I cannot figure it out.
I have to use brackets in a regular expression to show a bit of text is optional (i.e. it may or may not be there), but the problem with this is preg_match_all is interpreting the brackets as "write the content to the matches array".
Simple example:
$pattern = 'I want to save this "([^"])" to the matches array, but I don't want to save this optional text (may not be here)? to the matches array";
preg_match_all("/".$pattern."/U", $haystack, $matches);
So as you can see, I want the (["]) text to be saved, but the (may not be here)? pattern is just part of the regular expression, and I don't want it put in the array.
How can I do this?
Any help appreciated.
Thanks