>>>>> "APK" == Akhthar Parvez K <akht...@sysadminguide.com> writes:

  APK> Hi Uri,
  APK> On Wednesday 03 Nov 2010, Uri Guttman wrote:

  APK> $catch = $1 if ($string =~ /.*(E)\d*\b/);
  >> 
  >> he didn't say there will be digits at the end. what if there aren't? his
  >> example was just random text following the last E.

  APK> It will match even if there are no digits at the end:

so? then why even put it there?

  APK> input: $string = 'EEEEEEEfdgdfgfdEdffdgE'
  APK> output: $catch = E

try: 'EEEEE123EEExyz'

your \b at the end also breaks many cases.

perl -le 'print $1 if ("EE123EExyz" =~ /.*(E)\d*\b/)'
perl -le 'print $1 if ("EE123abc" =~ /.*(E)\d*\b/)'
perl -le 'print $1 if ("EE123EExyzE" =~ /.*(E)\d*\b/)'
E

the first two print nothing but the OP wants the last E.

uri

-- 
Uri Guttman  ------  u...@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to