I have a string and I want to remove the string Input! + word + digits and Calc! + word + digits from it. I have also included my attempt.
Input : IF(Input!B34 + Calc!B45)
Output : Input!B34 Calc!B45
My attempt :
Pattern findMyPattern = Pattern.compile("Input!\\w\\d|" + worksheetName+ "!.+?");
Matcher foundAMatch = findMyPattern.matcher(input);
HashSet hashSet = new HashSet();
while (foundAMatch.find()) {
String s = foundAMatch.group(0);
hashSet.add(s);
}
What regular expression should I use ? I tried using a few of them. But I am not expert in them. Some idea will be useful.
You can use this regex:
Explanation:
And use it with
Matcher#findand then addmatcher.group()to yourSet.