🖥

python で テキストから複数個のハッシュタグを正規表現で抽出して、結果を配列で得る

2019/02/02に公開

python で テキストから複数個のハッシュタグを正規表現で抽出して、結果を配列で得る

Example

import re

match = re.findall(r'(#[^\s]+)', 'I like #cat and #dog both.')

# ['#cat', '#dog']

One liner

>>> import re; match = re.findall(r'(#[^\s]+)', 'I like #cat and #dog both.'); match
['#cat', '#dog']

Original by Github issue

https://github.com/YumaInaura/YumaInaura/issues/550

チャットメンバー募集

何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

https://line.me/ti/g2/eEPltQ6Tzh3pYAZV8JXKZqc7PJ6L0rpm573dcQ

Twitter

https://twitter.com/YumaInaura

公開日時

2019-02-02

Discussion