SNYP40A1
December 2nd, 2008, 08:30 PM
In Perl, I can do a regular expression like this:
if($_ =~ /\s[\d:\d] = \d+/)
{
pinname = $1;
startindex = $2;
endindex = $3;
bitsettings = $4;
}
So for example, the pinname corresponds to the \s string and is given index 1 ($1) because it was the first subpart of the regular expression match. The first \d of the index was matched second and was assigned to $2, and so on... Is there a way to do exactly this in Java? I have looked at Java's Regex and pattern classes, but I don't see anything that can do this. In fact, for the above example, I don't think Java's regex class will save me much work over the simpler string split method.
if($_ =~ /\s[\d:\d] = \d+/)
{
pinname = $1;
startindex = $2;
endindex = $3;
bitsettings = $4;
}
So for example, the pinname corresponds to the \s string and is given index 1 ($1) because it was the first subpart of the regular expression match. The first \d of the index was matched second and was assigned to $2, and so on... Is there a way to do exactly this in Java? I have looked at Java's Regex and pattern classes, but I don't see anything that can do this. In fact, for the above example, I don't think Java's regex class will save me much work over the simpler string split method.