B
bahhab
Hi
The first code snip works but takes 4 lines and as there will be a
number of pattern matches I'd rather do each on one line. The second
snip is how I think it should work except I get "cannot resolve symbol
symbol : variable matcher". Is this possible and if so what should my
variable "matcher" be?
<snip>
Pattern regex = Pattern.compile("^(LRC[0-9]{5}).*");
Matcher match = regex.matcher(line);
boolean b = match.matches();
if (b) {id = match.group(1);}
<snip>
<snip2>
if (Pattern.compile("^(LRC[0-9]{5}).*").matcher(line).matches()) { /
id = matcher.group(1);}
<snip2>
The first code snip works but takes 4 lines and as there will be a
number of pattern matches I'd rather do each on one line. The second
snip is how I think it should work except I get "cannot resolve symbol
symbol : variable matcher". Is this possible and if so what should my
variable "matcher" be?
<snip>
Pattern regex = Pattern.compile("^(LRC[0-9]{5}).*");
Matcher match = regex.matcher(line);
boolean b = match.matches();
if (b) {id = match.group(1);}
<snip>
<snip2>
if (Pattern.compile("^(LRC[0-9]{5}).*").matcher(line).matches()) { /
id = matcher.group(1);}
<snip2>