I'm trying to split a string on its punctuation, but the string may contain URLs (which conveniently has all the typical punctuation marks).
I have a basic working knowledge of RegEx, but not enough to help me out here. This is what I was using when I discovered the problem:
$text[$i] = preg_split('/[\.\?!\-]+/', $post->text);
(this also accounts for multiple consecutive punctuation characters - ellipses, !!!!, ????, ?!?, etc)
How would I split a string on the punctuation while maintaining the integrity of URLs? Thanks!
Edit:
My apologies...an example would be something along the lines of a tweet:
"Blah blah blah? A sentence. Here's a link: http://somelink.com?key=value ."
The results should look something like this:
[0] => "Blah blah blah?"
[1] => "A sentence."
[2] => "Here's a link: http://somelink.com?key=value ."