<?xml version="1.0" encoding="windows-1252"?>
<node id="991028" title="Re^6: Regex: Identifying comments" created="2012-08-31 11:32:54" updated="2012-08-31 11:32:54">
<type id="11">
note</type>
<author id="920017">
pvaldes</author>
<data>
<field name="doctext">
&lt;c&gt;use strict; use warnings;

while (&lt;DATA&gt;) {
    chomp; 
    next if /^\s*--/;
    print $_,"\n" if !/--/;
    elsif (/--/ &amp;&amp; !/--(.*?);/){
         s/--(.*?)$//;
        print $_,"\n"}
    elsif (/--(.*?);\s*--(.*?)$/){
         s/\s*--$2//;
         print $_,"\n"}
    else { print $_,"\n"}
}

__DATA__
select 'text' from foo;       -- comment
select '--Not comment' from foo;        --But this is
select q from z; -- as is this
select '--Not this' + '--either' from foo;
select 'qaws' + make from "a"; -- comment with 'a' quote
select 'a' from 'b' with 'c' -- comment with 'a --' comment
-- test comment (add1)
select 'text\'s' from foo    --escaped  ... (add2)
select 'text\'s' from foo        --escaped'  ... (add3)
update set bar = bar - 1 ; -- subtraction symbol preserved
create table ( -- fo
field text, -- fufufu
field int)&lt;/c&gt;</field>
<field name="root_node">
990479</field>
<field name="parent_node">
990924</field>
</data>
</node>
