I would like to extract the following string <%MYSTRING123%>
from the example string below
'sdfsdf sdfsdf fd<%MYSTRING123%>d12df fsdsgsg d'
I found this exact question has been asked already, so i tried their solution as below:
$input = 'sdfsdf sdfsdf fd<%MYSTRING123%>d12df fsdsgsg d';
preg_match_all('/\[<%MYSTRING\](.*?)\[%>\]/', $input, $matches);
var_dump($matches);
Output
array(2) {
[0]=>
array(0) {
}
[1]=>
array(0) {
}
}
Expected Output
array(1) {
[0]=> '<%MYSTRING123%>'
}