SB-Books Posted January 22, 2015 Posted January 22, 2015 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
comment Posted January 22, 2015 Posted January 22, 2015 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.
SB-Books Posted January 22, 2015 Author Posted January 22, 2015 Thanks very much, Comment I am going to play with that right now Much appreciated! SB
Mark Scott Posted January 22, 2015 Posted January 22, 2015 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
SB-Books Posted January 22, 2015 Author Posted January 22, 2015 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!
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now