SPUG: RegEx

cmeyer at helvella.org cmeyer at helvella.org
Fri Sep 7 14:31:14 CDT 2001


At Fri, 7 Sep 2001 11:33:15 -0700 , "Brittingham, John" <john.brittingham at attws.com> wrote: 

>
>I am trying to replace a white space that lies between an number and a
>capital letter without changing either the number or the letter. I can't
>find any examples on this.. Can anyone tell me how to do this?
>
>example:
>6-2 Dual Mode Selection...... separating out Dual Mode Selection from 6-2

You might try something like:

$string =~ s/([0-9])\s+([A-Z])/$1$2/;

Parenthesis within a regex capture text that the containing 
subexpression matches.  These can be used withing the replacement
string, accessed as $1 $2 ... $n, with n being which parenthetical
pare, counted in the order that the opening parenthesis occur.

Have fun,
-C.

>
>Thanks jb
>

 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     POST TO: spug-list at pm.org       PROBLEMS: owner-spug-list at pm.org
      Subscriptions; Email to majordomo at pm.org:  ACTION  LIST  EMAIL
  Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
 For daily traffic, use spug-list for LIST ;  for weekly, spug-list-digest
     Seattle Perl Users Group (SPUG) Home Page: http://zipcon.net/spug/





More information about the spug-list mailing list