This is what I know:
- ^ inside brackets matches a character that isn't one of the included inside the brackets.
- + Matches one or more appearances of the expression to its left (in my ex. [^0-9]).
- $ If I'm not mistaken, matches to an expression that ends with the expression to its left.
Then it seems this expression should match input that has at least one character that isn't a digit and that ends with that expression, for example it should match: 1a, aaa, 2321a,1b1b
and should not match: 111, 432423,asd3213
but it is unclear to me from running this rule what exactly it matches.
This is my full code:
%option noyywrap
%{
#include<stdio.h>
%}
%%
[^0-9]+$ printf("not a number");
%%
int main()
{
yylex();
return 0;
}
And I'm using flex.
output examples(sorry for the links, it won't let me upload a photo):
[1] https://ibb.co/qp3hB0r - doesn't match but prints back
[2] https://ibb.co/syZHjrw - doesn't match and eats it (why does it happen if I didn't add ".|\n" in the code?)
[3] https://ibb.co/s6S0tQh - matches and prints back
[4] https://ibb.co/VmZW7KR - same as the 3rd
[5] https://ibb.co/2vPfWhc - matched only the 11(?) and ate up the aa
I'm really confused as to what it actually matches and would appreciate the help.