re.findall not returning full match?

前端 未结 5 1145
灰色年华
灰色年华 2020-11-28 10:29

I have a file that includes a bunch of strings like \"size=XXX;\". I am trying python\'s re module for the first time and am a bit mystified by the following behavior: if I

5条回答
  •  一整个雨季
    2020-11-28 11:02

    I think what you want is using [] instead of (). [] indicating set of character while () indicating group match. Try something like this:

    print re.findall('size=5[01];', myfile)
    

提交回复
热议问题