3.4.8
Python 3.4.8 (default, Apr 9 2018, 11:43:18)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-18)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import re
>>> re.search(r'b', 'abc').group(0)
'b'
>>> re.search(r'b', 'abc')[0]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: '_sre.SRE_Match' object is not subscriptable
3.7.2
Python 3.7.2 (default, Jan 13 2019, 12:50:01)
[Clang 10.0.0 (clang-1000.11.45.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import re
>>> re.search(r'b', 'abc').group(0)
'b'
>>> re.search(r'b', 'abc')[0]
'b'
ref
re — Regular expression operations — Python 3.7.3 documentation
Easy access to group! It seems like. Thanks python
By the way ruby example
[5] pry(main)> 'abc'.match(/b/)[0]
=> "b"
It may be easier to understand the dictionary
Original by Github issue
チャットメンバー募集
何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。