Python regular expressions extract the contents of parenthetical quotation marks in multiline strings.

recently learned python regular expressions, want to use regular expressions to extract the specified string in multiple lines

I have been searching the Internet for a long time, and there are a lot of people asking questions on the Internet, but they are all about the one-way situation. Ask the Great God for advice

example:

str = "jh2kn as.12an sss g2gs.Abc ("xxx") asdf;njkasahsda ng2gs.Abc ("yyy")"

extract xxx,yyy between "and"

< hr >

my own test is:

text = "xxx ("https://www.baidu.com/1.pngxxx")"
pattern = r" ^ (. +)? (". + (")) $"

the result: xxx ("https://www.baidu.com/1.pngxxx")
" actually I just want to get: https://www.baidu.com/1.pngxxx

it"s urgent


since you only want the content between double quotes, then group only those inside double quotes.

>>> p= re.compile('.+?"(.+?)"')
>>> p.findall('xxx("https://www.baidu.com/1.pngxxx")')
['https://www.baidu.com/1.pngxxx']
>>> p.findall('jh2kn as.12an sss g2gs.Abc("xxx")asdf;njkasahsda ng2gs.Abc("yyy")')
['xxx', 'yyy']

regular test

regular:

r"\(\"([^\"]*)\"\)"
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b2d0c6-2bb77.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b2d0c6-2bb77.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?