On Feb 7, Frank Newland said:

>I want to put a delimiter (#) between the rightmost number and the left most
>alpha

  s/(\d)([^\W\d])/$1#$2/;

You can't just say (\d)(\w), because \w INCLUDES \d.  You could write
something like (\d)(?!\d)(\w), which requires that the \w character after
the \d NOT be a \d.  However, you can use character class tomfoolery to
get it done.  [^\W\d] means "any character that is NOT:  a non-word char
or a digit".  If we take the opposite of that, we get:  "any character
that IS a word char and NOT a digit."  (Study deMorgan's laws if you don't
understand the opposition.)

Of course, if I got off my lazy ass, Perl 5.6.2 would support

  [\w^^\d]

which means "\w minus \d".

-- 
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