home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   alt.os.linux.slackware      I think its the one without Selinux crap      87,272 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 86,773 of 87,272   
   Eli the Bearded to Mike Spencer   
   Re: CORRECTION Re: regex question   
   01 Oct 24 22:09:19   
   
   From: *@eli.users.panix.com   
      
   In alt.os.linux.slackware, Mike Spencer  wrote:   
   > > I've never used regex's in vi/vim so beware.   
      
   They do differ from Perl. How different depends on version and config.   
   Elvis will be different from Vim. Vim has options to change this, etc.   
   Regexps are very sensitive to regexp engine in use.   
      
   > > I think Perl would say,   
   > >      s/]+)>//;   
   > > where "[^>]" is "any char not '>'".   
   > Apparently wrong. :-\   
   > From the command line:   
   >     perl -n -e 's/]+)>//;print;'   
      
   That command line is working perfectly for me. I would do it   
   differently, but that works.   
      
   $ echo '' | perl -n -e 's/]+)>//;print;'   
      
   $ echo '' | perl -n -e 's/]+)>//;print;'   
      
   $   
      
   You can shorten the one liner by using '-p' instead of '-n':   
      
      perl -p -e 's/]+)>//;'   
      
   The '-p' is "loop with printing' and '-n' is 'loop not printing'.   
      
   As for the regex, as my second example hints at, I'd change it to   
   require the leading whitespace, or at least not to alter existing   
   comments.   
      
      # require at least one space version   
      perl -pe 's/]+)>//'   
      
      # don't require a space, but don't alter previous output   
      perl -pe 's/][^>]*)>//'   
      
   Of course, the full HTML comment rules are notoriously a mess.   
      
   https://www.rfc-editor.org/rfc/rfc1866#section-3.2.5   
      
   Mostly, so long as $1 does not contain a double hyphen, the "don't   
   require a space, but don't alter previous output" will generate correct   
   output.   
      
   Elijah   
   ------   
   cannot guess how Mike Spencer's command was outputing single hyphens   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca