开发者

match a string of characters between tags:

I have the following strings:

<PAUL SAINT-KARL 1997-05-07>
<BOB DEAN 2001-05-07>
<GUY JEDDY 2007-05-07>

I want a java regex that would match this type of pattern "name and date" and then extract the name and date separately.

I able to match them separately with the following java regex:

   1) (\d{4}-\d{2}-\d{2})>

   2)  <([ A-Z&#;0-9-]*+)

What I'm looking for is one regex that would identify the full text pattern as provided, and then extract the subsections, such as the actual name, and the date.

I'm looking to use Match开发者_如何转开发er.group() to retrieve the complete match from the target string.

Thanks


Try this:

"<([ A-Z&#;0-9-]*?) (\\d{4}-\\d{2}-\\d{2})>"

I changed the *+ to *? to make the * match lazily.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜