gpt4 book ai didi

python - REGEX 字符串和转义引号

转载 作者:太空狗 更新时间:2023-10-30 01:42:55 24 4
gpt4 key购买 nike

<分区>

如何获取下面两段文字引号之间的内容?

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" """

对我来说问题是引号如果被转义应该被忽略,但是反斜杠有可能被转义。

我想获取以下组。

[
r'Some text on \"two\" lines with a backslash escaped\\',
r'Another text on \"three\" lines'
]

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com