Here is the question and required solution:
1.First Case:
String str = "Variable_1 in the range 0...4";
Solution: var1 = Variable_1 Range = 0...4
Pattern p1 = Pattern.compile("(.*[^.]) in the range of (.*[^.])$");
Matcher m1 = p1.matcher(desc);
if (m1.find()) {
System.out.println(m1.group(1));
System.out.println(m1.group(2));
}
2.Second Case:
String str = "Variable_1 in the range 0...4 Variable_2 in the range 10...40";
Solution:
var1 = Variable_1 range1 = 0...4 var2 = Variable_2 range2 = 10...40
3.Third Case:
String str = "Variable_1 in the range 0...4 Variable_2 in the range 10...40 Variable_3 in the range 10...50";
Solution:
var1 = Variable_1 range1 = 0...4 var2 = Variable_2 range2 = 10...40 var3 = Variable_3 range3 = 10...50
The first case works fine with the regex. I need to extend the same regex for the second and third cases. It should also be able to handle for n number of cases.