Jump to content
Sign in to follow this  
Peter Bowen

Wanted: cf to extract string between delimiters

Recommended Posts

I've looked and I can't find so please forgive if this has already been solved

I want to extract the url containing the word (or part of word) contact from a list of urls.

Here is an example of the raw list:

[23] http://192.168.0.200/FEEDBACK.HTM[24] http://192.168.0.200/ADVERTISE.HTM[25] http://192.168.0.200/CONTACTS.HTM[26]

I would like to have his returned:

http://192.168.0.200/CONTACTS.HTM

Any ideas would be appreciated (I've bashed my head against this for hours)

Cheers

Pete

Share this post


Link to post
Share on other sites

It looks like you need a little creative use of the script step: Position ( text ; searchString ; start ; occurrence ).

e.g. You could run a loop that finds words beginning with "http:" and loads them into a repeating field, then you would have all the addresses in the repeating field and it would leave out any other extraneous rubbish.

If the addresses come with the "[XX]" tacked on the end, you might also want to remove this as a step in the loop too.

Anatole

Share this post


Link to post
Share on other sites

It doesn't seem too difficult, but some points require clarification:

extract the url containing the word (or part of word) contact

1. What does "part of word" mean? Do words like "control" or "intact" contain part of the word "contact"?

2. Could there be more than one URL that needs to be extracted?

3. Does the number in brackets come after the URL or before it?

Share this post


Link to post
Share on other sites

I need the full word contact.

I've built a workaround for now which does the job

Make each url into a separate line by substituting the [ character for the newline character.

Using the custom function ExtractLine inside a script loop to pull each line and check it for "contact"

It's clumsy but it works for now. Can't spend all day solving one problem. I'd like to come back to it as I hate messy code.

Thanks

Pete

Share this post


Link to post
Share on other sites

I need the full word contact.

Well, that answers #1, and I guess from the rest that the answer to #2 is yes - but what about #3?

Share this post


Link to post
Share on other sites

Try a custom function:

ExtractContacts ( text )


Let ( [

pos = Position ( text ; "contact" ; 1 ; 1 ) ;

start = Position ( text ; "] " ; pos ; -1 ) + 2 ; 

end = Position ( text & "[" ; "[" ; pos ; 1 ) 

] ;

Case ( pos ; 

Middle ( text ; start ; end - start )

& ¶ &

ExtractContacts ( Right ( text ; Length ( text ) - end ) )

)

)

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.