in reply to Regular expression..
Here's the input I tried.#!/usr/bin/perl $/ = undef; $_ = <>; s/([^#"']*(['][^']*['])|(["][^"]*["]))|([#][^\n]*)/defined $1 ? $1 : " +"/gse; print;
and the output was:# comment. "this is a quote" # end of line comment. print "this is a multiline quite. #right? "; No comments at all. This is just general stuff. #this is a 'test too." '
Whaddya think? (I hope i typed the code in right. I do this on a separate machine)..."this is a quote" print "this is a multiline quote. # right? "; No comments at all. This is just general stuff.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Regular expression..
by choroba (Cardinal) on Oct 29, 2010 at 17:10 UTC | |
by raybies (Chaplain) on Oct 29, 2010 at 17:21 UTC |