0
我有一個字符串,我想從中刪除字符串Input! + word + digits
和Calc! + word + digits
。我也包括了我的嘗試。正則表達式:移除單詞和數字
Input : IF(Input!B34 + Calc!B45)
Output : Input!B34 Calc!B45
我嘗試:
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); }
我應該使用什麼正則表達式?我嘗試了使用其中的一些。但我不是他們的專家。一些想法會很有用。
你的例子輸出有'Calc!45',但輸入有一個'B'字符 - 是不是應該保存? – voithos 2013-02-13 19:36:10
@戰士。請記住將答案標記爲已接受。 – 2013-02-13 20:03:37
完成! ........ – AnujKu 2013-02-13 21:04:19