Hi Nick,
I'd like to start by thanking you profusely for creating the regex library. I see that this was some years ago, but it looks like it should solve my problem nicely.
Unfortunately, I have run into an issue. Probably my fault, but I can't figure out how. I have an expression that I'm searching for:
and I'm returning the list of captures per your example code:
It works great with one small issue that I'm trying to solve. The %d+ in the middle captures (or at least prints) nothing if the matched expression is at the beginning of the line. If I insert a space or one or more random characters before the text that I want matched, it works fine and I get my digits.
I've tried changing the expression to match the beginning of the line, and it didn't help my issue. I've also tried changing the %d+ to a %w+ thinking that maybe digits caused it, but there was no change (except that it would match on letters as well as digits, of course.)
Everything I've done does correctly print the leading "r" or "w" and the trailing alphanumeric character. Just not the digits in the middle if the string is at the beginning of the line.
Short of prefixing an extra character every time I send a code to match, I'm not sure where to go with this. Is this some gotcha with captures that I've just never heard of?
example output:
I would welcome your insights.
I'd like to start by thanking you profusely for creating the regex library. I see that this was some years ago, but it looks like it should solve my problem nicely.
Unfortunately, I have run into an issue. Probably my fault, but I can't figure out how. I have an expression that I'm searching for:
char result=ms.Match ("([rw])(%d+)(%w)");
and I'm returning the list of captures per your example code:
if (result == REGEXP_MATCHED)
{
Serial.println("Matched.");
for (int j = 0; j < 3; j++)
{
Serial.print ("Capture number: ");
Serial.println (j, DEC);
Serial.print ("Text: '");
Serial.print (ms.GetCapture (buf, j));
Serial.println ("'");
}
// matching offsets in ms.capture
}
It works great with one small issue that I'm trying to solve. The %d+ in the middle captures (or at least prints) nothing if the matched expression is at the beginning of the line. If I insert a space or one or more random characters before the text that I want matched, it works fine and I get my digits.
I've tried changing the expression to match the beginning of the line, and it didn't help my issue. I've also tried changing the %d+ to a %w+ thinking that maybe digits caused it, but there was no change (except that it would match on letters as well as digits, of course.)
Everything I've done does correctly print the leading "r" or "w" and the trailing alphanumeric character. Just not the digits in the middle if the string is at the beginning of the line.
Short of prefixing an extra character every time I send a code to match, I'm not sure where to go with this. Is this some gotcha with captures that I've just never heard of?
example output:
Attempting match on: r55t
r55t
Matched.
Capture number: 0
Text: 'r'
Capture number: 1
Text: ''
Capture number: 2
Text: 't'
Attempting match on: r55t
r55t
Matched.
Capture number: 0
Text: 'r'
Capture number: 1
Text: '55'
Capture number: 2
Text: 't'
I would welcome your insights.