如何用正则表达式找($ )内的内容
来源:百度知道 编辑:UC知道 时间:2024/05/26 01:01:31
‘($’ ‘)’
public static void main(String[] args) {
String content = "($abc)";
String regex= "\\(\\$(.*?)\\)";
Pattern p_regex = Pattern.compile(regex);
Matcher m_p_regex = p_regex.matcher(content);
if (m_p_regex.find()) {
System.out.println(m_p_regex.group(1));
}
}
想循环用while代替if