如何通过正则表达式拆分多行文本(How to split multiple line text by regex)
我有多行文字
SUBJECT=Testing001 TEXT=TestingLine001-Test TEXT=TestingLine002-Test REFER=Reference001 SUBJECT=Testing002 TEXT=TestingLine003-Test SUBJECT=Testing003 TEXT=TestingLine004-Test REFER=Reference002只想分割文本块(对于这种情况,三个文本块,“主题”是文本块的第一行),如:
SUBJECT=Testing001 TEXT=TestingLine001-Test TEXT=TestingLine002-Test REFER=Reference001 SUBJECT=Testing002 TEXT=TestingLine003-Test SUBJECT=Testing003 TEXT=TestingLine004-Test REFER=Reference002I have multiple lines text
SUBJECT=Testing001 TEXT=TestingLine001-Test TEXT=TestingLine002-Test REFER=Reference001 SUBJECT=Testing002 TEXT=TestingLine003-Test SUBJECT=Testing003 TEXT=TestingLine004-Test REFER=Reference002Just want to split text blocks (for this case, three text blocks, "Subject" is the first line of the text block) like as:
SUBJECT=Testing001 TEXT=TestingLine001-Test TEXT=TestingLine002-Test REFER=Reference001 SUBJECT=Testing002 TEXT=TestingLine003-Test SUBJECT=Testing003 TEXT=TestingLine004-Test REFER=Reference002最满意答案
(?=\bSUBJECT\b)(?!^)你可以使用这个split.See演示。
https://regex101.com/r/mG8kZ9/9
(?=\bSUBJECT\b)(?!^)You can use this split.See demo.
https://regex101.com/r/mG8kZ9/9
更多推荐
发布评论