i have pattern:
host=([a-z0-9./:]*)
it’s find for me host address. And i have content
host=http//:sdf3452.domain.com/
And my code is:
Matcher m;
Pattern hostP = Pattern.compile("host=([a-z0-9./:]*)");
m=hostP.matcher(content);//string 1
String match = m.group();//string 2
Log.i("host", ""+hostP.matcher(content).find());
if i delete string 1 and 2 i see true in logcat. If left as is I got exception nothing found.
I’ve tried all kinds of pattern. Through debug looked m variable, finds no match. Please teach me use reg exp!
Before you
group()a match, you need to invokefind().Try it like this:
EDIT
and a little demo that shows what each match-group contains:
which will print:
As you can see, group(0), which is the same as
group(), contains what the entire pattern matches.But realize that a URL can contain much more than what your defined in
[a-z0-9./:]*!