使用正则表达式在java中提取子字符串

Nir*_*ras 1 java regex

我需要"URPlus1_S2_3"从字符串中提取:

"Last one: http://abc.imp/Basic2#URPlus1_S2_3," 
Run Code Online (Sandbox Code Playgroud)

在Java语言中使用正则表达式.

有人可以帮帮我吗?我是第一次使用正则表达式.

Mik*_*uel 12

尝试

Pattern p = Pattern.compile("#([^,]*)");
Matcher m = p.matcher(myString);
if (m.find()) {
  doSomethingWith(m.group(1));  // The matched substring
}
Run Code Online (Sandbox Code Playgroud)


sfu*_*ger 5

String s = "Last one: http://abc.imp/Basic2#URPlus1_S2_3,";
Matcher m = Pattern.compile("(URPlus1_S2_3)").matcher(s);
if (m.find()) System.out.println(m.group(1));
Run Code Online (Sandbox Code Playgroud)

你必须学习如何指定你的要求;)