I am sadly not so familar with regex - so someone can help me with this? I have this string:
$theString = 'MYSTRING-[DDAADD]-IS_SO_BEAUTYFULL'
And all what I want is to extract the content between the 2 square brackets, in this example I should get 'DDAADD'.
The target is to explode my string that I get 3 strings:
$first = 'MYSTRING-';
$second = 'DDAADD';
$third = '-IS_SO_BEAUTYFULL';
How do I reach it?
I try it with preg_match but I can't get it to work:
preg_match('/[^a-zA-Z0-9\[\]]+/', $string, $matches);
I also try this:
preg_match_all('/[A-Z\[\]]+/', $string, $matches);
Then I got my three strings, but without the '-'..
I try it whith preg_split but I don't reach my target properly:
preg_split("/\[([^\]]+)\]/", $myString);
Then I got only my 2 strings correct, but without the central part with DDAADD...
Can someone help me with this?
DDAADDvalue? Orpreg_split('~[][]~', $s)to get 3 values like$first,$second, and$third?