Re: Extracting substring with regexp
- From: Lord Zoltar <lord.zoltar@xxxxxxxxx>
- Date: Thu, 31 Jan 2008 13:06:34 -0800 (PST)
On Jan 31, 3:52 pm, Alex <aki...@xxxxxxxxx> wrote:
How to extract substring with regexp when we have start and end for
substring?
For example I want to find what is between "abc" and "xyz" in the
String.
Pattern p = Pattern.compile("abc*xyz");
Matcher m = p.matcher("aaaaaaaaaabc123xyzzzzzzzzzzzzz");
but m.matches() returns false and can't find my patter.
How can I get these "123" in this example?
Alex Kizub.
You could try grouping:
(a+bc)(.+)(xyz+)
group 2 is the one that would have what you want.
.
- References:
- Extracting substring with regexp
- From: Alex
- Extracting substring with regexp
- Prev by Date: Extracting substring with regexp
- Next by Date: Re: Extracting substring with regexp
- Previous by thread: Extracting substring with regexp
- Next by thread: Re: Extracting substring with regexp
- Index(es):