對於字符串值"ABCD_12"
(包括引號),我想只提取的內容和排除了雙引號,即ABCD_12
。我的代碼是:正則表達式 - Java的
private static void checkRegex()
{
final Pattern stringPattern = Pattern.compile("\"([a-zA-Z_0-9])+\"");
Matcher findMatches = stringPattern.matcher("\"ABC_12\"");
if (findMatches.matches())
System.out.println("Match found" + findMatches.group(0));
}
現在,我已經嘗試過做findMatches.group(1);
,但只返回最後一個字符字符串中(我不明白爲什麼!)。
我該如何提取只留下雙引號的內容?
請嘗試提供具體標題問題 - 這個基本標題有幾十個問題 – DNA 2012-03-05 22:24:07