我刚开始使用正则表达式,我浏览了大量的教程,但是我还没有找到一个适用于我想要做的事情的教程,
我想要搜索某个内容,但是返回它后面的所有内容,而不是搜索字符串本身
例如“ 一些很棒的蹩脚句子”
搜索“ 判刑”
返回“ 太棒了”
如果你能帮忙,我将不胜感激
到目前为止,这是我的正则表达式
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");
}