我使用這個表達式(vb.net)來匹配字符串的所有標記,並保持分隔符(單獨捕獲組):正則表達式匹配的令牌,並保持分隔符
([^~\+\:]*)([~\+\:])
Text1+Text2::Text4::Text6~Text1+Text2:Text3+Text4~
輸出:
Text1 + Text2 : : Text4 : : Text6 ~ Text1 + Text2 : Text3 + Text4 ~
我怎樣才能實現與相同0作爲轉義分隔符(奇數?
)?
Text1+Text2?:Text3~
應導致
Text1 + Text2?:Text3 ~
感謝您的幫助
什麼會'文本1 +文本2 ??:文本3〜'返回?我的猜測是:'Text1 +','Text2? :'和'Text3〜'... – Sam
['(。*?)((?<![?])[〜\ + \:])'](http://regex101.com/r/bK8tH5/1)? – Sam
謝謝。但是這對多個'?'不起作用,'(。*?)'是一個性能殺手。 – user3525398