15,041
edits
No edit summary Tags: Mobile edit Mobile web edit |
|||
| Line 470: | Line 470: | ||
<pre> | <pre> | ||
[^\d|\n] | [^\d|\n] | ||
</pre> | |||
=== 尋找 Hashtag === | |||
* 因為連結包含 # 符號,所以需要事先處理。 | |||
* PHP code<ref>[http://stackoverflow.com/questions/3060601/retrieve-all-hashtags-from-a-tweet-in-a-php-function regex - Retrieve all hashtags from a tweet in a PHP function - Stack Overflow]</ref>: | |||
<pre> | |||
preg_match_all("/(#[^\s|\-|,|\"|,|\[|\]|『|』|/|~|(|)|(|)|【|】|《|》|-|「|」|!|!|、|?|:|…|:|#|\.|.|。|?]+)/ui", $string, $matches); | |||
</pre> | |||
* 還需要處理以下狀況 | |||
<pre> | |||
illegal | |||
#12345 | |||
#___ | |||
#_ | |||
#__123 | |||
legal | |||
#1_abc | |||
#_abc | |||
</pre> | </pre> | ||