Link to home
Start Free TrialLog in
Avatar of jillybabe
jillybabe

asked on

alphanumeric - finding one less!

Hi

I need some help to chamge the end character in a string of letters to the character or number which is one less based on alphanumeric characters and maintaining case

example string 1 - " /YEZ/NOZ1/B2FREE/fixed "
example string 2 - " /YEZ/NOZ1/B2FRE3/fixed "

I want to become

example string 1 - " /YEZ/NOZ1/B2FRED/fixed "
example string 2 - " /YEZ/NOZ1/B2FRE2/fixed "

I have tried using "$string =~ s/$end/$end -1/"

but it doesn't work becase it is not a number and sometimes it finishes with "a letter/fixed" sometimes "a number/fixed"

"fixed" is the known string which is always constant...
"/APHANUM/APHANUM/APHANUM/" is the dynamic bit and it is always the character before "/fixed" that I need to be one less...

Can anyone tell me how to do it?

thanks

Jilly  
ASKER CERTIFIED SOLUTION
Avatar of holli
holli

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of japhyRPI
japhyRPI

What should "BAA" decrease to?  "AZZ"?  And how about "FR0"?  That's a zero, so should it be "FQ9"?  We need more assistance with these boundary cases.  It's far easier to INCREMENT than to decrement.
Avatar of jillybabe

ASKER

Great that did it !

Thanks holli and you too japhyRPI

Jilly
Jilly, I'm just warning you that the current response turns "BAA" into "BA@", "FR0" into "FR/", and "STa" into "ST`".  To overcome these situations, you're going to need a slightly different regex.