Brian Dunning's FileMaker Custom Functions

StripText ( text )

Strips formatting, tabs, multiple spaces from text.

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

Tom Vincent   Tom Vincent
Nearly Normal Services
http://nearlynormalservices.com

Share on Facebook Share on Twitter

  Sample input:
StripText (Self)
  Sample output:
Clean, single-spaced text without tabs.

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

I use this all the time as an auto-enter calc for text fields that get crap pasted into them on a regular basis (email and URL fields are always coming in with underlines in that ugly blue). Just set the auto-enter calc to StripText (Self) and uncheck "Don't Replace Existing . . ."
Also great for Notes fields where users are pasting in all sorts of junk that needs to be cleaned up.
Of the few times I've seen real file corruption in FileMaker databases it has usually been bad input, like oddly formatted text or cross-platform font crap. I wrote this to help with that.
I've found that using Char () functions is more reliable and it has to be recursive for the double-space removal to work.
This iteration doesn't remove returns. Just stick another line in the Case argument to add that.
For real control, wrap the whole thing in a Filter () function, but then get checked for OCD.
NOTE: Fixed, 11/10/10, with apologies to anyone who lost time fooling around with the broken version.

 

Comments

Matt Wills   Matt Wills, Vermont
Oct 14, 2010
Unless I am missing something obvious, my FMPA 10 can't figure out on its own what CleanText is.
 
Tom Vincent   Tom Vincent, Nearly Normal Services
Oct 14, 2010
Sorry, that was a screwup.
I called the function "CleanText" but since there's already a "CleanText" on this board, I renamed it "StripText" and forgot about the self-references.
Thanks for catching that, it's fixed now.
tom
 
Jeep Watson   Jeep Watson, Baltimore
Nov 9, 2010
Sorry, I tried this a month ago and couldn't get it to work - even after repairing the self referenced name.

Thought I would give it another try. Still no go. I put it in an auto enter calc and enter some malformed text (carriage returns and tabs). As soon as I exit the field EVERYTHING disappears, not just the unwanted characters.
 
Tom Vincent   Tom Vincent, Nearly Normal Services
Nov 9, 2010
No really, this time it's fixed. I tested it.
I'd left out the last Case result which of course is the one that returns the cleaned up text.
That's why everything was disappearing, which is what I wish I could do right about now.

Sorry for the bother.
 
bb   bb, Hamburg
Apr 13, 2015
Works like a charm. Do not forget the
input parameter: Text
 
Peter   Peter, London
Dec 30, 2017
Imported text copied and pasted from an emailed internet form using Outlook ultimately show as text followed by a small, hollow square in a PDF.

I have yet to identify the alien character but this custom function does not clean it from the FM field as hoped.

Any suggestions?
 

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.