xExtractBetweenParentheses ( INPUT )
To extract a string, generally a URL, from between parentheses.
Average rating: 4.9 (17 votes) 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)
When building html strings from Markdown input we need to extract the URL from the Markdown before we construct the tagged html.
There are many ways of doing this but this is fast.
Comments
Carl Riedel, Curator Contender Mar 17, 2020 |
||
Hi... I used InsertFromUrl to get the contents of a sitemap (https://jakeshomeandgardenblog.weebly.com/sitemap.xml) Then I used the substitute function to place an opening and closing brackets around each url in the sitemap. When I ran this fuction though it only found the First Item in the list. Any ideas how I can make it find All the urls? Cheers, Carl |
||
Nick Lightbody, Deskspace Systems Limited Mar 17, 2020 |
||
Hi Carl For flexibility I suggest you start with the other version of this function 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.