Python Regex to find a string in double quotes within a string

后端 未结 4 1308
自闭症患者
自闭症患者 2020-11-29 06:06

A code in python using regex that can perform something like this

Input: Regex should return \"String 1\" or \"String 2\" or \"String3\" 
Output: String 1,St         


        
4条回答
  •  既然无缘
    2020-11-29 06:25

    Just try to fetch double quoted strings from the multiline string:

    import re
    
    str=""" 
    "my name is daniel"  "mobile 8531111453733"[[[[[[--"i like pandas"
    "location chennai"! -asfas"aadhaar du2mmy8969769##69869" 
    @4343453 "pincode 642002""@mango,@apple,@berry" 
    """
    print(re.findall(r'["](.*?)["]',str))
    

提交回复
热议问题