gpt4 book ai didi

java - 将文本拆分为文本末尾有 "spaces"的段落?

转载 作者:行者123 更新时间:2023-12-02 15:38:31 25 4
gpt4 key购买 nike

使用这个(?sm)^.*?\.$我从文本中检索每个段落。

当文本末尾有“空格”时,最后一段不匹配。我必须用什么来解决这个问题?

示例文本:

Copyright laws are changing all over the world. Be sure to check the
copyright laws for your country before downloading or redistributing
this or any other Project Gutenberg eBook.

This header should be the first thing seen when viewing this Project
Gutenberg file. Please do not remove it.

Please read the "legal small print", and other information about the
eBook and Project Gutenberg at the bottom of this file.

regex101 example

最佳答案

自从我从事学校项目以来,我使用 ((?:[^\n][\n]?)+) 。它会捕获至少用一行 (\n) 分隔的所有段落。

它的工作原理很简单:只需捕获除换行符之外的所有内容。

检查Regex101出来。

关于java - 将文本拆分为文本末尾有 "spaces"的段落?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40006371/

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