REGEX-String and escaped quote

后端 未结 4 1889
你的背包
你的背包 2020-12-19 12:05

How to get what is between the quotes in the following two texts ?

text_1 = r\"\"\" \"Some text on \\\"two\\\" lines with a backslash escaped\\\\\" \\
     +         


        
4条回答
  •  余生分开走
    2020-12-19 12:13

    >>> import re
    >>> text_1 = r""" "Some text on \"two\" lines with a backslash escaped\\" \
         + "Another text on \"three\" lines" """
    >>> text_2 = r""" "Some text on \"two\" lines with a backslash escaped\\" + "Another text on \"three\" lines" """
    >>> re.findall(r'\\"([^"]+)\\"', text_2)
    ['two', 'three']
    >>> re.findall(r'\\"([^"]+)\\"', text_1)
    ['two', 'three']
    

    Perhaps you want this:

    re.findall(r'\\"((?:(?

提交回复
热议问题