Brian Dunning's FileMaker Custom Functions

ReplaceInListƒ ( _list, _originalText, _replacementText )

Replace all instances of a value in a list.

  Average rating: 4.3 (31 votes) Log in to vote

Michael Rhodes   Michael Rhodes
Allied Data Service
http://allieddataservice.com

Share on Facebook Share on Twitter

  Sample input:
ReplaceInListƒ ( "a¶b¶c¶d¶b¶", "b", "e" )
  Sample output:
"a¶e¶c¶d¶e¶"

  Function definition: (Copy & paste into FileMaker's Edit Custom Function window)

Replaces all instances of a text parameter in an array with another text parameter.

 

Comments

bbb   bbb, melbourne australia
Mar 13, 2009
Last value should be return delimited also.

Let (
[ array = ¶ & array & ¶
; array = Substitute ( array; ¶ & originalText & ¶; ¶ & replacementText & ¶)
]
; Middle ( array; 2, Length ( array ) - 2 )
)
 
Michael Rhodes   Michael Rhodes, Rancho Cucamonga, CA
Mar 18, 2009
bbb,

Removed quotes around return characters. However, your use of the Middle function is wrong. Since an array is considered to be a value list, adding a character return to the end only serves a purpose if the value list is somehow missing the end return character. If the intent of your rewrite is to correct such an error, then removing the added end return character in the Let result defeats the purpose.

I have updated the defining of array to properly account for such an error.
 
Michael Rhodes   Michael Rhodes, Rancho Cucamonga, CA
Mar 18, 2009
Also updated function to replace all instances of found text, not just the first.
 

Log in to post comments.

 

Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.

Under construction. Email me your wish list for improvements.