Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Perl Beginners > Regex help?
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 3 Topic 11039 of 11065
Post > Topic >>

Regex help?

by sanket.vaidya@[EMAIL PROTECTED] (Sanket Vaidya) May 7, 2008 at 03:49 PM

------=_NextPart_000_0020_01C8B059.FA56F580
Content-Type: text/plain;
	charset="us-ascii"
Content-Transfer-Encoding: 7bit

HI all,

 

Kindly go through the code below.

 

use warnings;

use strict;

my $i=1;

while($i<=10)

{

$_ = "abcpqr";

$_=~ s/(?=pqr)/$i/;

print "$_\n";

$i++;

}

 

Output:

abc1pqr

abc2pqr

abc3pqr

abc4pqr

abc5pqr

abc6pqr

abc7pqr

abc8pqr

abc9pqr

abc10pqr

 

The expected output is

 

abc001pqr

abc002pqr

abc003pqr

abc004pqr

abc005pqr

abc006pqr

abc007pqr

abc008pqr

abc009pqr

abc010pqr

 

Can any one suggest me how to get that output using regex. i.e. Can this
happen by making change in regex I used in code??

 


------=_NextPart_000_0020_01C8B059.FA56F580--




 3 Posts in Topic:
Regex help?
sanket.vaidya@[EMAIL PROT  2008-05-07 15:49:47 
Re: Regex help?
krahnj@[EMAIL PROTECTED]   2008-05-07 03:46:09 
Re: Regex help?
rvtol+news@[EMAIL PROTECT  2008-05-07 16:16:09 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Thu May 15 1:13:19 CDT 2008.