我是使用Regex的新手,我已经看过许多教程,但没有找到适合我想要做的事情的教程,
我想搜索某些内容,但返回其后的所有内容,而不是搜索字符串本身
例如“一些很棒的la脚的句子”
搜索“句子”
返回“真棒”
任何帮助将非常感激
到目前为止,这是我的正则表达式
sentence(.*)
但它返回:很棒的句子
Pattern pattern = Pattern.compile("sentence(.*)");
Matcher matcher = pattern.matcher("some lame sentence that is awesome");
boolean found = false;
while (matcher.find())
{
System.out.println("I found the text: " + matcher.group().toString());
found = true;
}
if (!found)
{
System.out.println("I didn't find the text");
}
Matcher
吗?