如何使用regx匹配文本中的段落 [英] How to Match Paragraphs in Text with regx

查看:102
本文介绍了如何使用regx匹配文本中的段落的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用regxp从文本中提取所有段落,所以我想匹配第一个段落并遍历所有其他段落,我面临的问题是我无法使regxp成功匹配第一个段落,我会永远感谢您的帮助!

I need to extract all paragraphs from a text using regxp, so I figure to match first paragraph and iterate through all others, the problem I'm facing is I'm unable to make regxp to successfully match first paragraph, I would be forever grateful for help!

推荐答案

段落是写作的不同部分,用换行,缩进或编号表示

A Paragraph is a distinct section of a piece of writing,indicated by a new line, indentation, or numbering

所以,你可以做到

(\n|^).*?(?=\n|$)

将此regex与单行选项一起使用

Use this regex with singleline option

这篇关于如何使用regx匹配文本中的段落的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆