开发者

Regular expression Java, return the whole row?

I would like to get the whole row as my output. For example when i type kp1 I want the whole row CVBN.... returned.

begin abc
CVBN(r,t,t) + PPP(l,r) <-> ZEK(r!1).R(l!1,r) kp1,km1
TNBC(l,r) + SSR(r,t,t) <-> KPT(l,r!1).XXXX(l,r!1) kp2,km2
TLCX(l!+,(r,t,t)) + VV(l!+,r) <-> BB(l!+,r!1).R(l!+,r!1) kp3,km3
end abc

I tried the following:

Pattern pattern = Pattern.compile("kp1");
Matcher matcher = pattern.matcher(mytextFromAbove);

// Find all matches
while (matcher.find()) 
{
开发者_开发技巧    // Get the matching string
    match = matcher.group();
}

This only returns the substring kp1. Any help is really appreciated.

Thanks.


Change your expression to ^.*kp1.*$

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜