我有这样的模式
absint\(\s?(\$[A-Za-z0-9_]+)\s?\)\s?={2,3}\s?\g<1>|(\$[A-Za-z0-9_]+)\s?==\s?absint\(\s?\g<2>\s?\)
其中包含$id == absint($id)
或$id == absint($id)
等代码。它在https://regex101.com中使用preg_match函数可以正常工作,但PHPStorm不支持这种语法。如何在PHPStorm搜索中完成相同的操作?
答案 0 :(得分:1)
看起来你不能在PHP Storm中使用递归。你可以重复这个模式:
\w
请参阅regex demo(选择的JS风格不支持模式递归)。
[A-Za-z0-9_]
匹配字母,数字或下划线,如果是非Unicode感知的正则表达式,则等于absint\(\s?(\$\w+)\s?\)\s?={2,3}\s?\1|(\$\w+)\s?={2,3}\s?absint\(\s?\2\s?\)
xxxxxxx xx yyyyyyy yy
。
现在,如果您只想匹配两端的相同变量,您可以使用反向引用(而不是递归构造):
\g<1>
反向引用不会重复(重用)组模式(与(?1)
或$sql="SELECT * FROM Users WHERE Username='$username'";
if (!$result=mysqli_query($con,$sql))
{
die('Error: ' . mysqli_error($con));
}
else
{
$count=mysqli_num_rows($result);
}
if($count==1)
{
$hash = .$row['Password'];
if (password_verify($passfromform, $hash))
{
echo 'Password is valid!';
}
else
{
echo 'Invalid password.';
}
}
else
{
header("location:User Login.html");
}
一样),但它们是使用相应的文本的占位符基团。
请参阅Using Backreferences To Match The Same Text Again与Regular Expression Subroutines。