Skip to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Stripping a zero out of the middle of a string

Featured Replies

I have a key that looks like this: HF000151. I need to take a zero out of it. I need help with a script to do this. I have over a 1000 records I need to apply this change to and I don't want to go through and delete a zero on every record. The one tricky thing is that there are two different size keys, one is 8 chars & the other is 9 chars. If anyone could help out it would be great!

Thanks,

John

Make a calculated number field Length (TheKey) so that you can separate 8-digits from 9-digits keys ... you can get rid of it later on ...

The formula to remove a zero can be:

Left (TheKey,4) & Right (TheKey,3)

assuming the zeros are always in the same position

Once you've found the 8-digits keys run a Replace using the above formula, then use something similar for the 9-digits keys

If the zero you need to strip is in the same place in every record, i.e., the third character from the left, then you could do it this way. Set up a new calculation field where the calculation is a Replace function. It should look like:

Replace(KeyField, 3, 1, "")

You are replacing starting from the 3 character from the left (the "3"), and making your replacement one character long (the "1"), and replacing with nothing (the double quote).

If your zero needs to be dumped from a different position in different records, then you're in trouble. But if your records always have a string of three zeros that need to become a string of two zeros, regardless of position, then you could use the Substitute function instead.

Once this is done, you can convert the new field from a calculation field to whatever you need the key field to be, rename it, delete the original key field, and move the new one into place. Or you could temporarily change your key field's definition to a calculation and make the calculation simply the name of the new field. Once the db has done that, redefine the Key Field back the way it was and delete your new field.

Steve Brown

  • Author

That's what I was trying to do. The zero IS always the third character from the left. So this will work. Thanks for the replies!

John

Create an account or sign in to comment

Important Information

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

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.