Ver original$regex = '/#(\w+)/';$text = 'Texto de prueba #palabra blablablabla'; if (preg_match($regex, $text, $matches)) { echo $matches[1]; }