From: mds@bogus.nodomain.nowhere   
      
   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 '>'".   
      
   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".   
      
   I guess that would fail if you have any '>' chars withing your   
   comments. Hopefully not.   
      
   > I could do other sorts of search and replaces, but not using the (.*) and   
   > \1 combination.   
   >   
   > This was frustrating, because Pi kept telling me it should work. But it   
   > didn't. I'm wondering if I'm missing something?   
   >   
   > Of course my goal is to simplify the editing of the above bad comment,   
   > changing it to:   
   >   
   >    
      
      
   --   
   Mike Spencer Nova Scotia, Canada   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|