Reputation: 2801
Hey guys I am trying to ignore periods using preg_match, so:
$pos1 = preg_match( "/.*(#\S+)/", $currentStatus , $match );
$hash = $match[1];
This will grab the 2 hashtag in twitter API but lets say they have #hi. <- it will grab the . to, so if someone puts a . by accident I want it to ignore that.
Not sure how to do this and would appreciate the help!
David
Upvotes: 1
Views: 499
Reputation: 6647
preg_match('/(#\S+[^\.\s])/', $currentStatus, $match);
or
preg_match('/(#[a-zA-Z0-9]+)/', $currentStatus, $match);
Upvotes: 1
Reputation: 50643
Why don't you just remove the dot from the result:
$hash = str_replace('.','', $match[1]);
Upvotes: 3