PHPStorm is bundled with a Language Injection for Regexp using the <<<REGEXP HEREDOC expression. I would like to also have it auto detect Regexp written in strings. For this I tried to create a custom language injection entry (see attached export).
Unfortunately, my attempt does not seem to work but I also don't understand why it wouldn't work, so I'm interested if anyone has any idea on this.
Things I want to match:
$var = "/someregex/";
So to this end I added the following:
Which I expected to work but doesn't... what am I doing wrong? I at first also wanted the ending group [/#@] to match using a backreference for the first group (as "([/#@])" and "\1" or "$1") but this syntax wasn't accepted and as such also didn't work :-/
You are missing one important thing: the fact that no regex is used to describe matching string. It looks similar, but it is not a regex and this "^[/#@].*[/#@][gi]?$" simply will not work. Regex is simply too slow to be used here.
ATM you can only manually inject RegEx in such places as you edit them (Alt+Enter while standing inside the string).
Other than that: http://youtrack.jetbrains.com/issue/WI-1640
Aha... so do you happen to have a link to a reference page where the syntax is explained? Because I've been browsing the webhelp (http://www.jetbrains.com/phpstorm/webhelp/language-injection-settings-generic-php.html, and google) but haven't found a clear guide.
This seems to at least work for me, even though the solution might not be for everyone (and would still like to have a backreference for the ending delimiter)
The above solution actually matches all strings... so I definitely don't get how it works ;-]
Message was edited by: Doqnach .
I do not, unfortunately.
Maybe this one will be just a little bit better for your needs: http://www.jetbrains.com/phpstorm/webhelp/regular-expression-syntax-reference.html .
Unfortunately not. I am looking for documentation on the syntax used for building your own language injection triggers. As Andriy stated these are not actually regexp, but I can't find what their syntax is supposed to be (other than looking at the one for SQL and rewriting that like I showed in my previous post).
We don't consider this a "user serviceable" part..
plus we do some pre-processing in "matchesBrics": ' ' is replaced with <whitespacechar> and any UPPERCASE_CHAR with a group [cC].