Non-Greedy Regular Expression Matching in Flex
I have just started with Flex and can't seem to figure out how to match the following Expression : "Dog".*"Cat" ------------------ Input : Dog Ca Cat Cc Cat ------------------ Output: Dog Ca Cat Cc Cat But I want a non-greedy matching, with the following output : Output: Dog Ca Cat How can this be acheived on Flex ? EDIT Tried the following : %% Dog.*Cat/.*Cat printf("Matched : ||%s||", yytext); dog.*cat printf("Matched : ||%s||", yytext); dOg[^c]*cAt printf("Matched : ||%s||", yytext); DOG.*?CAT printf("Matched : ||%s||", yytext); %% Input : Dog Ca Cat Cc Cat dog Ca cat Cc cat dOg Ca cAt Cc c
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.