Home > Enterprise >  I use filemaker pro.... I am not any sort of programmer
I use filemaker pro.... I am not any sort of programmer

Time:10-08

I have a text field in FMPro...

Typical data entry:

<a href=http://www.example.com/images/224389.jpg target="_blank"> Photo available</a>.  

I would like to leave only:

http://www.example.com/images/123345.jpg

Is there a simple script / calculation that will strip off the <a href=" & " target="_blank"> Photo available</a>."

Thanks in advance!

CodePudding user response:

Assuming that your actual input looks like:

<a href="http://www.example.com/images/224389.jpg" target="_blank"> Photo available</a>

i.e. that there are double-quotes surrounding the href value, you could do:

Let ( [
start = Position ( YourField ; "href=\"" ; 1 ; 1 )   6 ;
end = Position ( YourField ; "\"" ; start ; 1 )
] ;
Middle ( YourField ; start ; end - start )
)

to extract:

http://www.example.com/images/224389.jpg

Another option you may want to consider is to install the (free) BaseElements plugin. Then you can do simply:

BE_XPath ( YourField ; "/a/@href"  ) 

CodePudding user response:

Let ( [
    _T ="<a href=http://www.example.com/images/224389.jpg target=\"_blank\"> Photo available</a>." ;
    _T = Middle ( _T ; Position ( _T ; "http" ; 1 ; 1 ) ; 10000 )
] ;
Middle ( _T ; 1 ; Position ( _T ; ".jpg" ; 1 ; 1 )   3 )

)

Replace the text with your field name in this calc. This calc assumes, all the image names are with extension .jpg

  • Related