简体   繁体   中英

Splitting string in java containing relational operators

Let's say I have a string which has relational operators:

"x<y , x=y , x<=y , x>y , x>=y" 

How can I split this?

If I use [<>=] it'll split x<=y as ( x and =y ).

Is there any simple way to do it without writing our own function to split?

If you want to split using any sequence of characters (and not only any character), then you should use:

[<>=]+

The + here means

You could have a Recursive Descent Parser. Is easy to implement and easy to mantain. You might want to look this .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM