Answer the question
In order to leave comments, you need to log in
How to make PhpStorm understand named groups in regular expressions?
PhpStorm says "This named group syntax is not supported in this regex dialect" but they actually work in PHP and have always worked. Where in the settings to report this to PhpStorm?
Here is a link to the place in the JetBrains code that generates this error: https://github.com/JetBrains/intellij-community/bl...
To make it clearer what I mean, here is a code example:
<?php
$stringUrl = 'https://sitename.org:80/full/path/?param1=1#anchor';
$stringRegexp = <<<'REGEXP'
#^((?<protocol>(https|http)):)?//(?<domain>[^/?\#:]+)(:(?<port>[\d]+))?(?<path>[^?\#]*)?(\?(?<params>[^\#]*))?(\#(?<anchor>.*))?$#usi
REGEXP;
if(preg_match($stringRegexp, $stringUrl, $arrayMatches)){
print_r($arrayMatches);
}
/*
Array
(
[0] => https://sitename.org:80/full/path/?param1=1#anchor
[1] => https:
[protocol] => https
[2] => https
[3] => https
[domain] => sitename.org
[4] => sitename.org
[5] => :80
[port] => 80
[6] => 80
[path] => /full/path/
[7] => /full/path/
[8] => ?param1=1
[params] => param1=1
[9] => param1=1
[10] => #anchor
[anchor] => anchor
[11] => anchor
)
*/
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question