fork download
  1. <?php
  2.  
  3. $code= 'Some text with [COLOR="red"]colored text[/COLOR] and [SIZE="7"]Big fonts[/SIZE] while "This double quote" is not matched';
  4.  
  5. preg_match_all('/\[.*?="(\w+)"\]/', $code, $matches, PREG_PATTERN_ORDER);
  6. for ($i = 0; $i < count($matches[1]); $i++) {
  7. echo $matches[1][$i]."\n";
  8. }
Success #stdin #stdout 0.01s 20568KB
stdin
Standard input is empty
stdout
red
7