$re = '/\#.*?(?=\s|\n|\#|$)/';
$str = '#3!x_j@`(/l3W#qfSnl#6R7x1b,jBb0p#Oq/:o#!tH3AITK^Yyp#B,
#qwe#%#T &#v#v#N###O###2#` `S}^&9 #M # Aa23%2##p#?#w#a
#123#9#Z a%h#&#C###;###? a#u#g#Q#r#8# #a#A#l#p#r#b#}#c
#R#M#(#p###K###l###1###b 2#D\\\'>.w/Y_2 sha2&2{] #4x$D~kR
#lbTb1k3# #Dlo ## #j# #W H#tjsR.Lzkc #B*xt&nFty?il#jp
#>p8BTU2###PW!aB###z###-VM (s82hdk#T 8sUJWfuy2#-#f~fh)
#d{jyi|^ofYD#q)!#special~!@$%^&*()#_+`-=[];\\\',./?><\\":}{';
preg_match_all($re, $str, $matches, PREG_SET_ORDER, 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