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? Quote 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); Quote 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. Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.