This is My String
14-Mar-16,RTRDTG78BGXPBE3H,D-Link DIR-600M Wireless N150 Home Router,10-Apr-16, SECEBH7HZMKZMG3B,Kaspersky Internet Security 2016 1 PC 1 Year
I want to split this string Where ever I find the pattern which I have Highlighted.
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It only takes a minute to sign up.
Sign up to join this communityThis is My String
14-Mar-16,RTRDTG78BGXPBE3H,D-Link DIR-600M Wireless N150 Home Router,10-Apr-16, SECEBH7HZMKZMG3B,Kaspersky Internet Security 2016 1 PC 1 Year
I want to split this string Where ever I find the pattern which I have Highlighted.
Looking at your string like this:
14-Mar-16,RTRDTG78BGXPBE3H,D-Link DIR-600M Wireless N150 Home Router,
10-Apr-16,SECEBH7HZMKZMG3B,Kaspersky Internet Security 2016 1 PC 1 Year
it appears to be a repeating pattern of 3 values separated by commas. If that is the case, personally I would just go for:
String[] parts = '14-Mar-16,RTR...Year'.split(',');
and deal with each piece based on its index in the parts
array:
for (Integer i = 0; i < parts.size(); i++) {
String part = parts[i];
Integer type = Math.mod(i, 3);
if (type == 0) use part as a date
else if (type == 1) use part as a code
else if (type == 2) use part as a name
}