From: mds@bogus.nodomain.nowhere   
      
   Mike Spencer writes:   
      
   > Joseph Rosevear writes:   
   >   
   >> Hello,   
   >>   
   >> This may be off topic, but let me try anyway.   
   >>   
   >> I've been editing HTML. I used to write my comments (incorrectly) like   
   >> this:   
   >>   
   >>    
   >>   
   >> I asked my AI friend, Pi, for help and he said do this in vim:   
   >>   
   >> :%s///g   
   >>   
   >> I've used vi, so I tried that and vim. I don't know if it matters.   
   >> Anyway, I got "No match found."   
   >   
   > I've never used regex's in vi/vim so beware.   
   >   
   > In perl, ".*" is greedy and, in the above locution, will eat up the   
   > '>', thus never separately finding the sought-for closing '>'.   
   >   
   > I think Perl would say,   
   >   
   > s/]+)>//;   
   >   
   > where "[^>]" is "any char not '>'".   
      
   Apparently wrong. :-\   
      
   From the command line:   
      
    perl -n -e 's/]+)>//;print;'   
      
   This fails. "]+)>//;   
      
   ???   
      
   > I think this might fail on multi-line comments if you tell perl to read   
   > the input file line by line (perl -n or while(<>) ).   
   >   
   > A workaround for that is to have a perl script read a whole file into   
   > a single variable $foo, then do the substitution on that var.   
   >   
   > $foo =~ s/]+)>//sg;   
   >   
   > where modifier 's' is "Treat the string as single line." and 'g' is   
   > "globally match the pattern repeatedly in the string".   
      
   In a script:   
      
    #!/usr/bin/perl   
      
    $x = '';   
      
    while(<>)   
    { $x = $x . $_;   
    }   
      
    $x =~ s/]+)>//sg;   
      
    print $x;   
      
   the regex works as I wrote that it should.   
      
   Sorry. It was late and I didn't test my own advice. Now trying to   
   figure out why the first one fails.   
      
   CAVEAT: You probably don't want to change the "
|