Substitute and replace

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

I have the below examples where I need to get the lastname using Perl
substitute and replace:
joeAAAAsmith jrAAAAbudget where I need to get smith jr
or this
GeneAAAAEvansAAAAmanager where I need to get Evans

I need to fetch just the lastname which will always be in between the
AAAA and AAAA delimeter: SteveAAAAJones-SingletonAAAAengineer where I
would need to get Jones-Singleton

I used the below and it worked but would like to know if this is the
most efficient way to do it?


Re: Substitute and replace

Quoted text here. Click to load it

Remember the old rule of thumb: if you know what to keep use s///, is
you know what to throw away use split():

    $lastname = (split /AAAA/, $foo)[1];


Site Timeline