问题:
I'm new to using Regex, I've been going through a rake of tutorials but I haven't found one that applies to what I want to do,我是使用 Regex 的新手,我已经阅读了一系列教程,但我还没有找到适用于我想做的事情的教程,
I want to search for something, but return everything following it but not the search string itself我想搜索一些东西,但返回它后面的所有内容而不是搜索字符串本身
eg " Some lame sentence that is awesome "例如“一些蹩脚的句子很棒”
search for " sentence "搜索“句子”
return " that is awesome "返回“太棒了”
Any help would be much appreciated任何帮助将非常感激
This is my regex so far到目前为止,这是我的正则表达式
sentence(.*)
but it returns: sentence that is awesome但它返回:这句话很棒
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");
}