Home>
①
$data = "< script>";
$ans = preg_replace ("/<[a-zA-Z] +. +?>/", "", $data);
print ($ans);//<script>
②
$data = "< script>";
$ans = preg_replace ("/<[a-zA-Z] +. +?>/", "", $data);
print ($ans);//<
We understand the behavior of ②,
In case of ①, just insert a space and you will not know why it matches the regular expression.
I know that ". +?" Is the shortest match in which any single character continues more than once
I don't know which metacharacters in the regular expression match the space.
-
Answer # 1
Is it different from what you expect?
* Beginning with "<" and ending with ">" for "one or more letters" or "one or more letters"
"<", "A", "", ">" hit in order, followed by "<" at the beginning and "scrit>" at the end
"