5
Hello, can someone please help me create a regex expression for the pattern below.
I have in my php code the following pattern: htmlspecialchars($str)
I need to create an expression that replaces that for this: htmlspecialchars($str,ENT_NOQUOTES,"UTF-8")
The expression must recognize the size of $str
and ignore it. After all, I hope that texts like the below have added to their end, the string: ENT_NOQUOTE,"UTF-8
.
For example: Where I have:
htmlspecialchars($table->content)
should stay that way:
htmlspecialchars($table->content,ENT_NOQUOTES,"UTF-8")
Where I have:
htmlspecialchars($_POST['title'])
should stay that way:
htmlspecialchars($_POST['title'],ENT_NOQUOTES,"UTF-8")
I would use in locating:
(htmlspecialchars\(\$.+?(?=\)))
and to replace:\1 ,ENT_NOQUOTES,"UTF-8")
– danieltakeshi
@danieltakeshi the idea is good, but if the author already has some other who is correct it will disturb those who have already been corrected (manually), so in my answer https://answall.com/a/279926/3635 I used a group with a negation that contains the comma
([^,])
, thus avoids replace being applied to strings that are already with,ENT_NOQUOTES,"UTF-8"
;)– Guilherme Nascimento