M
Markus Dehmann
This should be really easy, but I couldn't find it in the tutorials and
documentations on the web:
What is the Java equivalent to the following Perl operation?
my $entry = "__3432__Smith__"
my ($id,$name) =
$entry =~ m/__(\d+)__([A-z]+)__/;
In other words, I want to extract the number and the name from the
string $entry, using a regular expression.
I tried the following:
Pattern p = Pattern.compile("__([0-9]+)__([A-z]+)__");
Matcher m = p.matcher("__3432__Smith__");
while(m.find()){
System.out.println(m.group());
}
But that gives me the complete match at once, not the two subgroups that
I specified using the parens: (\d+) and ([A-z]+).
Who can help?
Thanks!
documentations on the web:
What is the Java equivalent to the following Perl operation?
my $entry = "__3432__Smith__"
my ($id,$name) =
$entry =~ m/__(\d+)__([A-z]+)__/;
In other words, I want to extract the number and the name from the
string $entry, using a regular expression.
I tried the following:
Pattern p = Pattern.compile("__([0-9]+)__([A-z]+)__");
Matcher m = p.matcher("__3432__Smith__");
while(m.find()){
System.out.println(m.group());
}
But that gives me the complete match at once, not the two subgroups that
I specified using the parens: (\d+) and ([A-z]+).
Who can help?
Thanks!