请帮忙!我需要创建代码/正则表达式以将以下文本解析为树:
some text I want to ignore==toplevel==
some text, with newlines maybe
===nextlevel===
more text. This is a child node of 'toplevel'
===anotherchild===
this is a sibling of 'nextlevel' and a child of 'toplevel'====leaf====
this is a child of 'anotherchild'
====leaf2====
sibling of 'leaf' & child of 'anotherchild'
===child3===
this is a sibling of 'anotherchild' and 'nextlevel' and a child of 'toplevel'
等等。你明白了。
我无法阻止子级别与顶层匹配。我试过 ={2} 但 === 和 ==== 仍然匹配。只需获得一个匹配 '==toplevel==' 之后的所有文本的匹配将是一个开始。我似乎无法忽略/吃掉换行符。
非常感谢任何帮助!查理。