Q:

PHP - RegExp get the last hashtags part of a tweet

Let be a tweet posted as the following examples:
any #kind of @characters here #hashtag1 #stunning #hasthag2 [just punctuation here]*
any #kind of @characters here #hashtag1 #hashtag2 #stunning [just punctuation here]*
any #kind of @characters here #stunning #hashtag1 #hashtag2 [just punctuation here]*

I need a regural expression which returns the last part of the tweet, that is, the ending n+ hashtag, knowing that one of them (in any position) will be a known one (e.g. #stunning).
My current implementation is: 
(.*)(((#[^\s]+)[ ]?)*(#stunning)[ ]?((#[^\s]+)[ ]?)*)([\W]*)

http://regex101.com/r/rX3kM1/1
PHP Code:
$tweet = "any #kind of @characters here #hashtag1 #hashtag2 #stunning !!?!?...";
preg_match("/(.*)(((#[^\s]+)[ ]?)*(#stunning)[ ]?((#[^\s]+)[ ]?)*)([\W]*)/", $tweet, $match);
print_r($match);

Output:
Array
(
    [0] => any #kind of @characters here #hashtag1 #hashtag2 #stunning !!?!?...
    [1] => any #kind of @characters here #hashtag1 #hashtag2
    [2] => #stunning
    [3] =>
    [4] =>
    [5] => #stunning
    [6] =>
    [7] =>
    [8] => !!?!?...
)

Desidered Output:
Array
(
    [0] => any #kind of @characters here #hashtag1 #hashtag2 #stunning !!?!?...
    [1] => any #kind of @characters here 
    [2] => #hashtag1 #hashtag2 #stunning
    ...
)

A:

If I understand you correctly the following regex should do it:
^(.*?)((?:#\w+\W*)*(?:#stunning)\W*?(?:#\w+\W*?)*)(\W*)$

http://regex101.com/r/rX3kM1/5
It matches the last occurence of #stunning and any hashtags before and after that. Only non word charcter are allowed between them and after the last one.
The last hastags are in group 2, the text before in group 1 and the punctuation directly after the last is in group 3.

