gpt4 book ai didi

python - 正则表达式帮助 - 分隔符

转载 作者:行者123 更新时间:2023-12-01 04:38:00 25 4
gpt4 key购买 nike

- Dropbox login fix
- Updated iris viewer
* other aspects are to be improved
+ fix crash on viewing update
? Photos in notes now support copy, cut and paste - By long pressing a photo in a note, you can access the context
menu for copy, cut and paste of the photo. The photo can be pasted to any place in the text of notes.
Do you like the version? Please take the time to leave a review whenever you update the app.

我需要检索带有分隔符(-、*、+ 以及我在下面使用的其他一些分隔符)的句子。因此寻找类似的输出:

['Dropbox login fix', 'Updated iris viewer', 'other aspects are to be improved', 'fix crash on viewing update', Photos in notes now support copy, cut and paste - By long pressing a photo in a note, you can access the context menu for copy, cut and paste of the photo. The photo can be pasted to any place in the text of notes.']

使用正则表达式,例如:

r = re.split(r'(?m)\s*^[-*:;+&.?]+\s*|\.$',txt)

但这也会返回最后一行,这是我不想要的。这种没有分隔符的自由文本可能/可能不会出现在我正在处理的文本中。

最佳答案

不要为此使用split。使用这个正则表达式:

^\s*[-*:;+&.?]+\s*(.+)$

re.findall() 函数中获取所有匹配项。

RegEx Demo

关于python - 正则表达式帮助 - 分隔符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31390470/

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