java - RegEx - 每组行一组
问题描述
假设我有一个文本文件,其内容类似于以下内容:
021 Line one of section A.
021 Line two of Section A.
021 Line three of section A.
021 Part two of Line three of Section A.
021 We just skipped line four, but that's okay.
021 Back to line six.
Non-formatted lines to be ignored. This can be from 0 lines, to any number of lines, and the content can be any text.
033 Line 1 of Section B
033 Line 2 of Section B
033 Okay, that's enough.
是否可以在正则表达式中给我两组,第一组包含以 开头的所有行,021
第二组包含以 开头的所有行033
?
行标记会有所不同,但始终是\d{3}
.
解决方案
推荐阅读
- gradle - 如何在 gradle 中使用命令行标志禁用远程构建缓存
- c# - 在 office vsto 加载项中区分自动保存和常规保存的方法
- flask - 如何使用默认文件创建 WTForms FileField?
- elasticsearch - 使用 Kibana 中的新模式获取“数组中的对象没有得到很好的支持” Kibana
- mongodb - How to apply validation of a Model which is having a ref?
- rust - 如何通过函数中的可变引用重新分配数组
- python - Krispy_forms.exceptions.CrispyError: |as_crispy_field 传递了一个无效或不存在的字段
- r - 通过网站收集数据 在 R 中下拉数据
- laravel - Laravel 关系管理多列,
- magento - 如何在 Magento 2.3.2 的结帐过程中删除付款方式步骤