regex - php get all matches string in text after "@" character -


i have function want set text return match string text :

function get_matches(){     $string = "@text1 @text2 text here #text3 #text4 @text5 ";     // set test string.      // set regex.     $regex = 'what regex here';      // run regex preg_match_all.     preg_match_all($regex, $string, $matches);      // dump resulst testing.     echo '<pre>';     print_r($matches);     echo '</pre>';  } 

the result :

array( [0] => array     (         [0] => text1         [1] => text2         [2] => text5     )) 

how can write appropriate regex right result.

this regex should work you:

$regex = '/@(\s+)/'; 

output:

array (     [0] => array         (             [0] => @text1             [1] => @text2             [2] => @text4             [3] => @text5         )      [1] => array         (             [0] => text1             [1] => text2             [2] => text4             [3] => text5         )  ) 

Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -