Returns one or more subgroups of the match. If there is a single argument, the result is a single string; if there are multiple arguments, the result is a tuple with one item per argument. Without arguments, group1 defaults to zero (the whole match is returned).
.group()和.group(0)一样,返回的是全部的匹配内容
wmttom
2015-04-21 14:15:06 +08:00
>>> import re >>> re.search(r"(?<=\()\S+?(?=\))", "aa(bbb)ccc").group()
200cc
2015-04-21 15:31:04 +08:00
var s = 'aa(bbb)ccc'; var r = /\((.*)\)/g; var result = r.exec(s)[1]; // bbb