Yang Rui Yang Rui - 1 year ago 70
Java Question

how to split this with regex

i want to split a string:


into following array:


i use split("day|hour|minute"),got this


how to handle?thanks!

Answer Source

Try this

String res = Arrays.toString("1day2hour3minute".split("(?<=(day|hour|minute))"));
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download