🖥

#python の正規表現で名前付きキャプチャグループを使う例 ( ?P<name> )

に公開
>>> re.search(r'(?P<first_name>^\w+)', "Alice Liddle")['first_name']
'Alice'
>>> re.search(r'(?P<last_name>\w+$)', "Alice Liddle")['last_name']
'Liddle'

Original by Github issue

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

チャットメンバー募集

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

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

Twitter

https://twitter.com/YumaInaura

公開日時

2019-04-10

Discussion