問題:
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");
}