AskandLearn has asked for the wisdom of the Perl Monks concerning the following question:
Another Perl regex question to match comments and strings
Requirement/regex spec/what should be matched and what should not
double or single quotes strings are not strings if inside comments
# inside strings are not comments
Here is an example, strings and comments needs to be captured and HTML style tags will added to highlight them later
# this is a comment, should be matched. # "I am not a string" . 'because I am inside a comment' my $string = " #I am not a comment, because I am quoted"; my $another_string = "I am a multiline string with # on each line #, have fun!";
I tried few things, could not work out a solution to cover all the situations.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Multiline string and one line comments
by kcott (Archbishop) on Apr 16, 2014 at 05:53 UTC | |
by Anonymous Monk on Apr 16, 2014 at 07:09 UTC | |
by AskandLearn (Initiate) on Apr 18, 2014 at 02:45 UTC | |
by Anonymous Monk on Apr 18, 2014 at 02:48 UTC | |
by AskandLearn (Initiate) on Apr 18, 2014 at 03:13 UTC | |
| |
by AskandLearn (Initiate) on Apr 18, 2014 at 02:50 UTC | |
by AnomalousMonk (Archbishop) on Apr 18, 2014 at 04:03 UTC | |
| |
|
Re: Multiline string and one line comments
by davido (Cardinal) on Apr 16, 2014 at 14:59 UTC | |
|
Re: Multiline string and one line comments
by Laurent_R (Canon) on Apr 16, 2014 at 09:13 UTC | |
by AskandLearn (Initiate) on Apr 18, 2014 at 03:15 UTC |