Brian Dunning's FileMaker Custom Functions

SubstituteWildcardRange ( text ; searchString ; replaceString )

Replace a wildcard expression with another wildcard expression.

  Average rating: 2.9 (85 votes) Log in to vote

Howard Schlossberg   Howard Schlossberg - Show more from this author
FM Professional Solutions
http://fmprosolutions.com

Share on Facebook Share on Twitter

  Sample input:
1)
SubstituteWildcardRange ( "FileMaker", "*", "*")

2)
SubstituteWildcardRange ( "FileMaker", "*", TextStyleAdd("*"; Bold) )
  Sample output:
1)
FileMaker

2)
FileMaker (in bold)

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

Similar to SubstituteRange, this function can be used to replace a portion of text, given beginning and ending text. But unlike SubstituteRange, this function utilizes a wildcard character ("*") to keep the text between the beginning and ending text. This can be great for replacing format tags, either as HTML or within a FileMaker field (using any of FileMaker's text formatting functions).

By using an asterisk (as the wildcard character) in the middle of the searchString, and anywhere in the replaceString, this custom function will retain the unknown text between your known beginning and end text/tags.

4/15/2011: fixed the recursion call, as it was calling an incorrect function name.

 

Comments

belg4mit   belg4mit
Mar 4, 2019
Add the following to the Case statement before the default option, in order to support uses like:
SubstituteWildcardRange("FileMaker,3", ",*[pilcrow]", ""), which can be used to remove arbitrary endings of strings.

ptBegin > 0 and ptEnd ≥ lenEnd and modText ≠ text; modText;
 

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.

Support this website.

This library has been a free commmunity resource for FileMaker users and developers for 20 years. It receives no funding and has no advertisements. If it has helped you out, I'd really appreciate it if you could contribute whatever you think it's worth: