$re = '/(#.*\s*)/';
$str = 'This is one of the amazing Mountains you can find in the National Forest Park in #Zhangjiajie #Chinawhich is where James Cameron drew his inspiration for the flying mountains in #Avatar..
Credit: @phototravelnomads
#pictoura #gydr
#destinationearth #earthpix #ourlonelyplanet#wonderful_earthLife #timeoutsociety#fantastic_earthpics #liveoutdoors #igglobalclub#awesomeearth #mist_vision #earthdeluxe
# #worldbestgram #mthrworld #fantastic_earth#famouscaptures #destination_wow #dreamlifepix#wonderful_places #igworldclub #ig_global_life
#natureaddict #beautifuldestinations #traveler #guider#locals';
preg_match($re, $str, $matches, PREG_OFFSET_CAPTURE, 0);
// Print the entire match result
var_dump($matches);
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for PHP, please visit: http://php.net/manual/en/ref.pcre.php