In PERL, I'm trying to use a regular expression that will replace two digits at the beginning of a string with 'testtext'. There will be instances of strings that have 0, 1, 2, and more digits at the beginning, but I only want to substitute 'testtext' for those strings that have EXACTLY two digits at the beginning. For instance:

1Sallywentthisway --> gets skipped in the replace for having only 1 digit 00tomwentthatway --> 00 is replaced with testtext 123joestayedstill --> gets skipped in the replace for having over 2 digits 11Billisgone --> 11 is replaced with testtext

This line of PERL code is not enough:

$segment =~ s/^\d{2}/testtext/;

That code will change the 123joestayedstill to testtext3joestayedstill

OK, you may try gratuitious sarcasm as you wish, but you should know that it is considered good practice to inform people about cross posting on this type of forum. You are asking people to help you, it is nice to tell people that are trying to help you for free that you have asked the question elsewhere and that the right answer might have already provided. This might avoid duplicate work from people who are trying to help you for free. In the case in point, you have received the relevant (and I think correct) answer on Perl Monks, why should people here spend time trying to give you an answer that you already have?

Kenosis is spending a lot of effort trying to help other people such as you on this forum and on others, please don't discourage him. Please avoid this kind of sarcasm next time, it is not nice toward people who are trying to help you for free.

I was being honest...and serious. I was helped a great deal and sincerely appreciative. I was even inspired to do something else and found the answer to be similar to the one I was given. I didn't know the answer was found on another site before this one.