ParseValueByBookends ( )

Function stats

Average user rating
532
401
9999
Support
FileMaker 7.0 +
Date posted
07 August 2016
Last updated
11 August 2016
Version
Recursive function
No

Author Info
 David Moyer

6 functions

Average Rating None

author_avatar



 

Function overview

Prototype

ParseValueByBookends  ( text;   leftSideTag;   rightSideTag )


Parameters

text  the text to be parsed


leftSideTag  the data immediately preceding the desired value


rightSideTag  the data immediately following the desired value


Description

Tags:  XML   text parsing   name/value pairs  

SIMPLE TEXT PARSER:
This is called "simple" because it has obvious limitations*. But it can be real handy too.
Use it for parsing name value pairs ...
e.g. ParseValueByBookends ( $myText; "city="; "¶" ) ...
xml, html, etc.


* - The main limitation is that it simply returns the first occurrence

Examples

Sample input

ParseValueByBookends ( $myXML; "<Response>"; "</Response>" )


Sample output

Success

 

Function code

// www.davidmoyer.net

Let(

[

posL = Position(text; leftSideTag; 1; 1);

posR = Position(text; rightSideTag; posL + 1; 1);

leftStart = posL + Length(leftSideTag)

];

If(posL > 0 and posR > posL;

Middle(text; leftStart; posR - leftStart);

""

)

)


// ===================================
/*

    This function is published on FileMaker Custom Functions
    to check for updates and provide feedback and bug reports
    please visit http://www.fmfunctions.com/fid/401

    Prototype: ParseValueByBookends( text; leftSideTag; rightSideTag )
    Function Author: David Moyer (http://www.fmfunctions.com/mid/532)
    Last updated: 11 August 2016
    Version: 2.0

*/
// ===================================

 

 

 

 

 

 

 

Top Tags

Text Parsing  (33)
List  (31)
Date  (28)
XML  (26)
Format  (23)
Sql  (22)
Dev  (20)
Debug  (17)
Interface  (15)
Layout  (15)
Text  (14)
Variables  (12)
Layout Objects  (11)
Filter  (11)
Design  (10)
Array  (7)