I have a string like:

{A}{B}={C}{D}<{E}{F}<=

What I want to do is split that string using a regular expression so as to get something like:

1: {A}{B}=
2: {C}{D}<
3: {E}{F}<=     

I'm currently splitting the string using (?<=\>)|(?<=\<\=)|(?<=\>\=)|(?<=\=)|(?<=\<)|(?<=!\=) but it's not producing the desired result, as you can see:

1: {A}{B}=
2: {C}{D}<
3: {E}{F}<
4: =

What do I need to change in the regular expression to get the result I'm looking for?

有帮助吗?

解决方案

Try this instead:

(?<=<=)|(?<=>=)|(?<=!=)|(?<==(?!=))|(?<=<(?!=))|(?<=>(?!=))

Or use match instead of split with this simpler regular expression:

.*?(?:<=|>=|!=|=|<|>)
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top