Last active
October 8, 2018 07:21
-
-
Save mlshvdv/d399a073014319b68bf5d8ae260fa10c to your computer and use it in GitHub Desktop.
Regexp to extract a hashtag with emoji support PCRE (php)
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 | |
| $string = ' | |
| #abc123_ | |
| #машина | |
| #anytest😀 | |
| #какой_тотекст😁 | |
| #😂 | |
| #🤣 | |
| #😃 | |
| #😄 | |
| #😅 | |
| #😆 | |
| #😉 | |
| '; | |
| // Supports any language | |
| preg_match_all('/#((?:[\pL_0-9]|([0-9#][\x{20E3}])|[\x{00ae}\x{00a9}\x{203C}\x{2047}\x{2048}\x{2049}\x{3030}\x{303D}\x{2139}\x{2122}\x{3297}\x{3299}][\x{FE00}-\x{FEFF}]?|[\x{2190}-\x{21FF}][\x{FE00}-\x{FEFF}]?|[\x{2300}-\x{23FF}][\x{FE00}-\x{FEFF}]?|[\x{2460}-\x{24FF}][\x{FE00}-\x{FEFF}]?|[\x{25A0}-\x{25FF}][\x{FE00}-\x{FEFF}]?|[\x{2600}-\x{27BF}][\x{FE00}-\x{FEFF}]?|[\x{2900}-\x{297F}][\x{FE00}-\x{FEFF}]?|[\x{2B00}-\x{2BF0}][\x{FE00}-\x{FEFF}]?|[\x{1F000}-\x{1F6FF}][\x{FE00}-\x{FEFF}]?)+)/u', $string, $matches); | |
| print_r($matches); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment