I'm attempting to write a simple lexer in python. I'm using regular expressions to do it. So, I need a regular expression matching a multiline comment:
/* first line.
the second line
The last line. */
By using this pattern:
pattern = r"/\*.*\*/"
and compiling it with
regex = re.compile(pattern,re.DOTALL)
it works.
Now, i won't use re.DOTALL
, 'cause this works also with single-quoted strings.
Is there a way to compile this expression in order to work without re.DOTALL?