I have seen that there are some posts regarding the Java Matcher class, but I was not able to find one regarding the specific methods find() and group().
I have this piece of code, where Lane and IllegalLaneException have already been defined:
private int getIdFromLane(Lane lane) throws IllegalLaneException {
Matcher m = pattern.matcher(lane.getID());
if (m.find()) {
return Integer.parseInt(m.group());
} else {
throw new IllegalLaneException();
}
}
Looking at the Java Documentation, we have the following:
find() - Attempts to find the next subsequence of the input sequence that matches the pattern.
group() - Returns the input subsequence matched by the previous match.
My question is, which is the equivalent to the methods find() and group() in C#?
EDIT: I forgot to say that I am using the MatchCollection class together with Regex
C# code:
private static Regex pattern = new Regex("\\d+$"); // variable outside the method
private int getIdFromLane(Lane lane) //throws IllegalLaneException
{
MatchCollection m = pattern.Matches(lane.getID());
...
}