textmate/php.tmbundle

Syntax Highlighting of Regular Expressions in HEREDOC and NOWDOC

NoNoNo opened this issue · 1 comments

In PHP I use heredoc and nowdoc for writing Regular Expressions:

$a = <<<REGEX
/
  ^
    .*  # Match all
  $
/x
REGEX;
$a = <<<'REGEX'
/
  ^
    .*  # Match all
  $
/x
REGEX;

Often I use the PCRE_EXTENDED mode (ignores whitespace and comments), activated by

  • by the /x flag: /RegEx/x or
  • by prepending (?x): /(?x)RegEx/

I would like to see a syntax highlighting

  • of the embedded regex in heredoc and nowdoc and
  • of regex in PCRE_EXTENDED mode in general

Thanks & Greetings

Added this using the REGEX delimiter. I added support for using comments in any regex heredoc as it can't test for the presence of the x flag, it's conservative in what it will match to limit false positives. Matching comments in the regular string form is more complicated and would take some improvements in the regular expression matching in general.