On Jan 24, Naveen Parmar said:

>s/^([^ ]+) +([^ ]+)/$2 $1/;

[^ ] means "any character that is not a space.

I think this regex would generally be written better as:

  s/(\S+)(\s+)(\S+)/$3$2$1/;

This swaps the first two chunks of non-whitespace.  That would turn my
previous sentence into "swaps This the first two chunks of
non-whitespace."

-- 
Jeff "japhy" Pinyan      [EMAIL PROTECTED]      http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **
<stu> what does y/// stand for?  <tenderpuss> why, yansliterate of course.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to