Brian Dunning's FileMaker Custom Functions

ExplodedString_Work ( field )

Exploded String Variant

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

Michael Alexander   Michael Alexander - Show more from this author
none
no website

Share on Facebook Share on Twitter

  Sample input:
The brown fox
  Sample output:
T
Th
The
The
The b
The br
The bro
The brow
The brown
The brown
The brown f
The brown fo
The brown fox
b
br
bro
brow
brown
brown
brown f
brown fo
brown fox
f
fo
fox

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

First, thanks to those who came up with the idea to explode stings in order to do searches on a field. The power of this technique is enormous and I did some work to create a slightly different result as well as handle some of the side cases that were not handled well in the previous versions.

The previous version of exploded string did not work for my application, plus I created a bit of parsing to handle input that wasn't clean. The support functions to handle unclean input include:

This handles: Leading Spaces, Trailing Spaces, and double (triple,etc) spaces in the input.

MyExplodedString (field):
ExplodedString_Work(RemoveSpaceSpace(TrimLeftSpace(TrimRightSpace(field))))

TrimLeftSpace(field):
Let ( [ nospaces=Substitute(Field; " "; "") ];
If (IsEmpty(nospaces); ""; Right(Field; Length(Field) + 1 - Position(Field; Left(nospaces; 1); 1; 1 ))))

TrimRightSpace(field):
Let ( [ nospaces=Substitute(Field; " "; "") ];
If (IsEmpty(nospaces); ""; Left(Field; Position(Field; Right(nospaces; 1); Length(Field); -1 ))))

RemoveSpaceSpace(field):
If (PatternCount(field; " ") = 0; field; RemoveSpaceSpace(Substitute(field; " "; " ")))

 

Comments

Daniel Harlow   Daniel Harlow, Pasadena, CA
Dec 10, 2009
The above function should be:

Let(Counter = PatternCount(field; " ");
Case(
counter = 0; ExplodedString_Work(field);
counter > 30; "ERROR: too many fields";
ExplodedString_Work(field) & "¶" &
ExplodedString_Work(Right(field; Length(field)-Position(field;" ";1 ; 1)))))
 
Michael Kupietz   Michael Kupietz, Michael Kupietz FileMaker Consulting
Jul 15, 2014
Doesn't work. You forgot to include an exit condition, it just gives an out of memory error.
 

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: