Issue with Regular expressions in python

前端 未结 6 919
轮回少年
轮回少年 2021-01-21 20:59

Ok, so i\'m working on a regular expression to search out all the header information in a site.

I\'ve compiled the regular expression:

regex = re.compile         


        
6条回答
  •  春和景丽
    2021-01-21 21:21

    Because of the braces around the anchor tag, that part is interpreted as a capture group. This causes only the capture group to be returned, and not the whole regex match.

    Put the entire regex in braces and you'll see the right matches showing up as the first element in the returned tuples.

    But indeed, you should use a real parser.

提交回复
热议问题