Brian Dunning's FileMaker Custom Functions

PickTagContent ( Text ; Prefix ; Suffix )

Pick strings between Prefix and Suffix without Prefix and Suffix itself.

  Average rating: 4.6 (26 votes) Log in to vote

Koji Takeuchi   Koji Takeuchi
TonicNote, Inc.
https://tonic-note.com

Share on Facebook Share on Twitter

  Sample input:
PickTagContent ( "abc<>def<>" ; "<<" ; ">>" )
  Sample output:
foo¶bar

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

PickTagContent ( Text ; Prefix ; Suffix )
2012.09.07, Koji Takeuchi


description:
Pick strings between Prefix and Suffix without Prefix and Suffix itself.
ex.
Text = "abc<>def<>"
PickTagContent ( Text ; "<<" ; ">>" )
= "foo¶bar"

If you want to pick strings with Suffix and Prefix, try PickTag ( Text ; Prefix ; Suffix ).

 

Comments

Bruce Robertson   Bruce Robertson
Sep 17, 2012
Nice function! I am curious about case sensitivity for the tags.

Compare results for this:

Let(
X = PickTagContent ( "abc<foo>
<bar>BAR1</bar><bit>X1</bit>
<bar>BAR2</bar><bit>X2</bit>
<bar>BAR3</bar><bit>X3</bit>
<bar>BAR4</bar><bit>X4</bit>
</foo><bar>BAR</bar>" ; "<foo>" ; "</foo>" );
List(
PickTagContent(X; "<bar>"; "</bar>");
PickTagContent(X; "<bit>"; "</bit>")
)
)

Result:
BAR1
BAR2
BAR3
BAR4
X1
X2
X3
X4
(next)
 
Bruce Robertson   Bruce Robertson
Sep 17, 2012
vs this (capitalize first char of closing tag)

Let(
X = PickTagContent ( "abc<foo>
<bar>BAR1</bar><bit>X1</bit>
<bar>BAR2</bar><bit>X2</bit>
<bar>BAR3</bar><bit>X3</bit>
<bar>BAR4</bar><bit>X4</bit>
</foo><bar>BAR</bar>" ; "<foo>" ; "</foo>" );
List(
PickTagContent(X; "<bar>"; "</bar>");
PickTagContent(X; "<bit>"; "</Bit>")
)
)
Result:
BAR1
BAR2
BAR3
BAR4
X1</bit>
X2</bit>
X3</bit>
X4</bit>
(next)
 
Bruce Robertson   Bruce Robertson
Sep 17, 2012
vs this (true mismatched closing tag)
Let(
X = PickTagContent ( "abc<foo>
<bar>BAR1</bar><bit>X1</bit>
<bar>BAR2</bar><bit>X2</bit>
<bar>BAR3</bar><bit>X3</bit>
<bar>BAR4</bar><bit>X4</bit>
</foo><bar>BAR</bar>" ; "<foo>" ; "</foo>" );
List(
PickTagContent(X; "<bar>"; "</bar>");
PickTagContent(X; "<bit>"; "</bxit>")
)
)
Result:
BAR1
BAR2
BAR3
BAR4
 

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.