Jump 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.

Parsing out a substring... multiple instances...?

Featured Replies

Hello,

 

I am a FM newbie and have been scouring the web for an answer to this problem:

 

I want to eliminate the text within parentheses in a string, but I want to eliminate all instances:

 

ORIGINAL STRING:

This is a test of the (emergency) broadcast system. (It is only a test). Remain calm.

 

DESIRED STRING: 

This is a test of the broadcast system. Remain calm.

 

Can anyone help?

 

Also, is it possible to tie the function or script to a field so that when the ORIGINAL string is put into the field, the field does the conversion automatically?

 

thanks very much in advance,

 

SB

I want to eliminate the text within parentheses in a string,

 

If you eliminate all text within parentheses, you will end up with:

"This is a test of the  broadcast system. . Remain calm."

You can clean up the runs of spaces by using TrimAll() on the result, but the extra period in your example is outside the parentheses.

 

 

This would probably be best done with a custom recursive function, but you can try a hack in the form of:

Let (
formula = Substitute ( Quote ( Textfield ) ; [ "(" ; ""  & /*" ] ; [ ")" ; "*/ "" ] )
;
Evaluate ( formula )
)

Note that this will fail miserably if the text contains unbalanced parentheses.

 

 

Also, is it possible to tie the function or script to a field so that when the ORIGINAL string is put into the field, the field does the conversion automatically?

 

You can set the field to auto-enter a calculated value (using the above formula), replacing the existing value.

  • Author

Thanks very much, Comment

 

I am going to play with that right now

 

Much appreciated!

 

SB

Very clever approach, comment!  Agree that a recursive function is probably the way SB should go, but I love the lateral thinking that went into your approach.

 

Mark

  • Author

Comment, your solution worked great.

I also played with a custom function to further clean up the text: http://www.briandunning.com/cf/1227

 

thanks again!

Create an account or sign in to comment

Important Information

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

Account

Navigation

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.