Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
次のコードを実行し、最初の ')' のみを一致として取得しました。通常の貪欲な '))' が返されない理由を誰かが教えてくれますか?
r=re.compile('\)') var=r.search('- hi- ))there') print var.group()
Your regex isn't greedy. In fact, it's set up to match only a single character. If you want it to match repeats as well, add a +:
+
>>> r=re.compile('\)+') >>> var=r.search('- hi- ))there') >>> print var.group() ))