January 22, 201511 yr 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
January 22, 201511 yr 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.
January 22, 201511 yr Author Thanks very much, Comment I am going to play with that right now Much appreciated! SB
January 22, 201511 yr 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
January 22, 201511 yr 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