我需要将章节标题拆分为标题编号和标题名称。章节标题格式为:
some long text
3.7.2 sealant durability
paragraph with text // (.*)
3.7.3 funkční schopnost
paragraph with text...
3.1.13 plastic sealant xx 21
paragraph with text
3.1.14 plastic sealant
xx 21
paragraph with text
3.7.12 sealant durability
paragraph with text
3.7.325 funkční schopnost
编辑: 问题是,说明值在长文本之间,充满特殊字符。
我曾经遵循代码,但它只在最后一个点之后拆分了最后一个数字。当我在最后一个“\d”之后填充一个“+”字符时,会引发错误。这个问题的正确正则表达式是什么?
title.trim().split("(?<=(\\d\\.\\d{1,2}\\.[\\d]))")
预期输出:
splitedValue[0] : '3.7.2'
splitedValue[1] : 'sealant durability'
...
splitedValue[0] : '3.1.14'
splitedValue[1] : 'plastic sealant xx 21'
...