Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

Looping script to remove last two charecters in a field..but only if those charecters are letters and not numbers.


This topic is 6129 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

Hi everyone,

If it weren't for one condition this would be a pretty easy script for me. But alas, because of the condition I have no idea how to do this or even if it is possible.

I have a text field where ID numbers will have a suffix of sm, md, lg or no suffix at all. ex 123456789sm. 123456789md, 123456789lg, 123456789.

What I want to do is create a new field that will capture the suffix information.

I need to write a script to pull the last two charecters of the ID number and place them in the new field but only if the last two charecters are letters and not numbers.

This is a classic example of where I should have created the DB with two fields and then used a calculation to combine into one ID number but the need to do this developed long after the soltuion was developed and users started adding the suffix on their own. Now I need to go back and fix the mess. I did not anticipate this.

Any help would be greatly appreciated.

Thanks,

Steve

Posted

Right (YourField; 2)

or maybe

Filter (YourField; "abcdefghijklmnopqrstuvwxyz)

Using the SetField ( for either of these should do it)

Lee

Posted

In your new field a simple Replace Field Contents by Calc =

Filter( Right (OldField; 2) "smdlg")

then in your old Field, Replace Field Contents =

Left(oldField; Length(oldField)-2)

&

Filter( Right(OldField);2) ; "0123456789")

This topic is 6129 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.