Brian Dunning's FileMaker Custom Functions

MatchX ( string ; search )

Matches consecutive characters only l-r not r-l yet

  Average rating: 3.8 (46 votes) Log in to vote

Ian Moree   Ian Moree
Somethings Different
http://somethingsdifferent.biz

Share on Facebook Share on Twitter

  Sample input:
MatchX( "MYnamE1" ; "E1 )


MatchX( "BahmiaN" ; "Lk" )
  Sample output:
E1


There was no Match

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

Matches a set of characters such as

Ia

BA

U1

 

Comments

Lee Smith   Lee Smith
Mar 29, 2012
Was this working for you?
 
Ian Moree   Ian Moree, Nassau Bahamaas
Mar 29, 2012
WOW!
totally messed up the copy / paste

Here is what i intended to past>

/*
###################################

Match v.1_0
by: Ian moree
date: Mar 29, 2012

Definition: Match ( string; search ; )

eg. this finds chars in sequence {IA} , if not, then returns Message stating so
// My first custom function- I am sure there is room for improvement,just dont know yet!

#####################################
*/


Case
( IsEmpty( string) or IsEmpty( search ); "" ;
/* else */
Let( [

len = Length ( search );
pos = Position( string; search ; 1 ;1 )
];


Case( pos = 0 ; 0 ; Exact (search; Middle ( string ; pos; len ) )
) )
)
 
Lee Smith   Lee Smith
Mar 30, 2012
Initially I noticed that you had a typo in the Let statement

POS = Position (text; search; 1:1)

S/B POS = Position (string; search; 1; 1)

In addition you had the opening case statements closing within the Let calculation, instead of at the end where it belonged.

I tested your revised Custom Functions and I noticed that you modified the calculation for the Let so that it no longer gives statement “there was no match”

Anyway, here is a modification of your original custom function, that I think does what you wanted to do.

Case (
IsEmpty ( text ) or IsEmpty ( Search ) ;
Get ( LastError ) ;
Let ( [
len = Length ( Search ) ;
pos = Position ( text ; Search ; 1 ; 1 )
] ;
Case (
pos = 0 ;
"There was no Match" ;
Middle ( text ; pos ; len )
)
)
)
//end case
 
Ian Moree   Ian Moree, Nassau Bahamaas
Mar 30, 2012
thanks Lee.
 

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.