python re.search中如何去掉,
# group组匹配匹配 name mable 和 years 时,如何将mable后的逗号除去呢
# 需求
# 1、将 name is mable,im 18 years. 匹配出来
# 2、将 name,mable,years 匹配出来
test = ' My name is mable,im 18 years old.'
result_37 = re.search('My(.*)years.', test)
result_38 = re.search('My(.*)is(.*)im.*18(.*)old', test)
# result_38 = re.search('\wMy(.*)is(.*)im.*18(.*)old', test)
# result_38 = re.search('[a-z]?My(.*)is(.*)im.*18(.*)old', test)
result_39 = result_38.groups()
print(result_39)
RE: python re.search中如何去掉逗号
[b]回复 [url=http://www.bathome.net/redirect.php?goto=findpost&pid=225312&ptid=54380]1#[/url] [i]小渣飞[/i] [/b]页:
[1]