http://v2.freep.cn/3tb_131023134156kqj9512293.jpg
urlContent1 获取不到匹配的内容,但是urlContent2可以 两个只差一个空行,
在正则上也加了跨行属性,为什么不能匹配呢?求解
——————以下是图片中的代码的文本部分——————
urlContent1 ='''
111
222
'''
urlContent2 ='''111
222
'''
global_pattern = re.compile('111',re.S|re.I|re.M)
globalMatch = global_pattern.match(urlContent1)
if globalMatch:
globalContent = globalMatch.group()
print 'urlContent1 match' + globalMatch.group()
globalMatch = global_pattern.match(urlContent2)
if globalMatch:
globalContent = globalMatch.group()
print 'urlContent2 match' + globalMatch.group()
urlContent1 获取不到匹配的内容,但是urlContent2可以 两个只差一个空行,
在正则上也加了跨行属性,为什么不能匹配呢?求解
——————以下是图片中的代码的文本部分——————
urlContent1 ='''
111
222
'''
urlContent2 ='''111
222
'''
global_pattern = re.compile('111',re.S|re.I|re.M)
globalMatch = global_pattern.match(urlContent1)
if globalMatch:
globalContent = globalMatch.group()
print 'urlContent1 match' + globalMatch.group()
globalMatch = global_pattern.match(urlContent2)
if globalMatch:
globalContent = globalMatch.group()
print 'urlContent2 match' + globalMatch.group()