Drkcore

24 11 2010 Python Tweet

Pythonの正規表現で最長マッチと最短マッチ

基本は最長マッチ、最短マッチさせたい時には?をつける

>>> import re
>>> a = "ABABABABAB"
>>> re.search(r'(AB)+',a).group()
'ABABABABAB'
>>> re.search(r'(AB)+?',a).group()
'AB'

すぐに忘れるのでメモ

About

  • もう5年目(wishlistありマス♡)
  • 最近はPythonとDeepLearning
  • 日本酒自粛中
  • ドラムンベースからミニマルまで
  • ポケモンGOゆるめ

Tag

Python Deep Learning javascript chemoinformatics Emacs sake and more...

Ad

© kzfm 2003-2021