Reputation: 29
When I write the regular expression on https://regex101.com/ \*.*?\* on dddd *ssssdedc* ddddddd I get the *ssssdedc* part.When I write this on a php file:
echo '<br />';
echo preg_match('/\\\*.*?\\\*/','dddd \*ssssdedc\* ddddddd',$matches);
echo '<br />';
var_dump($matches);
I get an empty string.Any suggestion?
Upvotes: 0
Views: 20
Reputation: 57121
When you do the match, the extra \
you've included are making the strings not match. You only need to escape things like \
if you need it in the end result...
preg_match('/\\*.*?\\*/','dddd *ssssdedc* ddddddd',$matches);
var_dump($matches);
gives...
array(1) {
[0] =>
string(10) "*ssssdedc*"
}
Upvotes: 1