[英]Regex extract everything except a pattern (string in quotes)
我有一個類似input = "I really like "Game of Thrones"
(用引號顯示)的字符串,我只想提取I really like
但我無法獲得正確的正則表達式來做到這一點。像這樣的東西不起作用re.search(".*^(?!\\".*\\")", input)
。
我可以做類似re.sub('".*"','', input)
事情re.sub('".*"','', input)
但我很難找到非子,使用re.search
方法提取。
干得好:
input = 'I really like "Game of Thrones"'
output = re.sub('"[a-zA-z0-9 _\.]+"','',input)
print(output)
輸出:
I really like
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.