xExtractBetweenDelimiters ( text ; delimiter )
a cf to extract text between delimiters used when passing codes / tags embedded in plain text for processing into html / css an essential part of the kit for the creation of web pages from markdown or similar input.
Be the first to rate this function Log in to vote
Nick Lightbody - Show more from this author
Deskspace Systems Limited http://deskspace.com |
Function definition: (Copy & paste into FileMaker's Edit Custom Function window)
cf1a: a cf to extract text between delimiters
used when passing codes / tags embedded in plain text for processing into html / css
an essential part of the kit for the creation of web pages from markdown or similar input.
Comments
Nick Lightbody, Deskspace Systems Limited Mar 17, 2020 |
||
Additional Note: If you want to extract a series of delimited strings from the source string. xExtractBetweenDelimiters You need to cycle through the input, so the function finds the first one - then finds the second one The p2 value should become the new p1 because the Position() 3rd and 4th parameters specify where to start in the string and which occurrence to get. As the delimiters are the same for the beginning and end you will want to get the following occurences: 1st 3rd 5th etc as the 2nd 4th etc will be "more text" and "and more text" in the example below? So under FMP18: (1) use patterncount() to count how many occurences of the delimiter occur in the string and use this ($delimiterNumber) to create an exit condition to exit the loop when: $count > $delimiterNumber; (2) you can run a loop in your script, specify $count=1 and then call the custom function with $count as the 4th parameter - then set $count = $count+2 etc for the next call the second time around the loop. xExtractBetweenDelimiters ( text ; delimiter, occurrence ) So try modifying the function as shown below.. Let me know how you get on. Cheers, Nick /* extract function */ xExtractBetweenDelimiters ( text ; delimiter, occurrence ) Let([ s=Substitute("textstring |for extraction| more text |for more extraction| and more text";"\"";"\\" & "\""); x=Evaluate(Quote( s )); p1=Position(x;delimiter;1;occurrence)+1; p2=Position(x;delimiter;1;occurrence+1); L=p2-p1; y=Middle(x;p1;L); z=Substitute(y;"\\";"") ]; z ) /* end of function */ |
||
Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.