3 Write regular expressions for these programming language c
3 Write regular expressions for these programming language constructs: a. Comment of the form “%%” to the end of line (as in a=1; %% this is a comment). You can use $ or eoln for end-of-line, or you can use the convention that “.” matches any character except eoln. b. Binary numbers with decimal point (as in 101.111, may not start 0, must have digits before and after .) c. Identifiers in Python (letter or underscore, followed by zero or more letters, underscores, digits)
Solution
1) %%$ (or) .*%%\ (Since . means any number of occurences)
2) 1[01]*\\.[01][01]*
3) ([a-zA-Z]\\_)([A-Za-z_0-9])*
