Last active
November 30, 2016 10:50
-
-
Save saiik/b8d8db703b823965ceaaa0334852b1d1 to your computer and use it in GitHub Desktop.
Filter @mentions and #hashtags from a string
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Filter @mentions and #hashtags from a string | |
| * | |
| * @author saiik<saikon@hotmail.de> | |
| * @license GPLv3 | |
| */ | |
| $str = 'Hello @saiik! #php #github'; | |
| preg_match_all('/@\w+/', $str, $mentions); | |
| preg_match_all('/#\w+/', $str, $hashtags); | |
| var_dump($mentions); | |
| var_dump($hashtags); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment