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.

Replace tags in calculated result

Featured Replies

Hello, I'd like to be able to hold simple tags within my data that can be replaced in a calculated field with a full anchor on export:

'domain.co.uk'

and replace with

'domain.co.uk'

Any help would be greatly appreciated.

Try something like =


Let ( [

open = Position ( text ; "[url]" ; 1 ; 1 ) ; 

close = Position ( text ; "[/url]" ; open ; 1 ) ;

url = Middle ( text ; open + 5 ; close - open  - 5) ;

bef = Left ( text ; open - 1 ) ;

aft = Right ( text ; Length ( text ) - close - 5 ) 

] ;

Case ( open ; 

bef & "" & url & "" & aft ;

text

)

)

This will handle the first URL in text. If text can contain multiple URL's, you will need a recursive custom function or a script to further process the aft part.

  • Author

Many thanks, that worked a treat, I doubt we'll have more than once instance in a column - but... is there a simple way of doing this recursively/nesting it? Thanks again R

To do it recursively, you need to create a custom function.

Say you name your function process_url_tag(text), then you could modify the code to be something like


Let ( [

open = Position ( text ; "[url]" ; 1 ; 1 ) ; 

close = Position ( text ; "[/url]" ; open ; 1 ) ;

url = Middle ( text ; open + 5 ; close - open  - 5) ;

bef = Left ( text ; open - 1 ) ;

aft = Right ( text ; Length ( text ) - close - 5 ) 

] ;

Case (

(open > 0) and (close = 0); "Syntax Error: Missing close url tag";

(open = 0) and (close > 0); "Syntax Error: Missing open url tag";



open ; 

bef & "" & url & "" & process_url_tag(aft) ;

text

)

) 

If you lack the tools to create a custom function, you could apply the original calculation repetitively in a script using a Set Field step. Place a handful of identical Set Field or Replace Field Contents steps in a row to handle the maximum number of tags you expect to find, or put it in a loop designed to exit when no more pairs are found.

Edited by Guest

It's not too difficult to make it a custom function:

TransformURLs ( text ) =


Let ( [

open = Position ( text ; "[url]" ; 1 ; 1 ) ; 

close = Position ( text ; "[/url]" ; open ; 1 ) ;

url = Middle ( text ; open + 5 ; close - open  - 5) ;

bef = Left ( text ; open - 1 ) ;

aft = Right ( text ; Length ( text ) - close - 5 ) 

] ;

Case ( open ; 

bef & "" & url & "" & TransformURLs ( aft ) ;

text 

)

) 

  • Author

Thanks chaps, That worked a dream, if you ever find yourself in the Lord Raglan (Kent, UK) I'll buy you a pint or two!

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.