I have a string like this:
test_0001_suiteid_111_leavepolicy_employee
When I split this in java using regular expression like this:
_(?=.*_)
It shows ouptut like this:
test
0001
suiteid
111
leavepolicy_employee
But if I use this string:
test_0001_suiteid_111_leavepolicy
It shows ouptut like this:
test
0001
suiteid
111_leavepolicy
Can you please explain why this is happening. I want the output same as first output using a common regular expression.
_after the_you split against. What are your requirements for splitting? BTW, have a look at this demo._(no regex needed) and limit the number of elements you want back.