Trel Posted October 12, 2010 Share Posted October 12, 2010 my example line is preg_match_all("/[.]+/","The quick brown fox jumped over the lazy dogs.",$matches); I would expect it to match the whole thing, but what it actually matches is the period. How would I make that match the whole line in this case? Link to comment https://forums.phpfreaks.com/topic/215692-match-not-working-as-expected/ Share on other sites More sharing options...
sasa Posted October 12, 2010 Share Posted October 12, 2010 try preg_match_all("/.+/","The quick brown fox jumped over the lazy dogs.",$matches); Link to comment https://forums.phpfreaks.com/topic/215692-match-not-working-as-expected/#findComment-1121423 Share on other sites More sharing options...
salathe Posted October 12, 2010 Share Posted October 12, 2010 Cags answered this on IRC (remember to come back and update posts!), for the benefit of other readers the dot character is not special within a character class (square brackets); i.e. it was only matching the literal dot. Link to comment https://forums.phpfreaks.com/topic/215692-match-not-working-as-expected/#findComment-1121424 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.