| View previous topic :: View next topic |
| Author |
Message |
DW Contributor

Joined: 21 Mar 2003 Posts: 175 Location: UK
|
Posted: Fri Jul 18, 2003 2:39 pm Post subject: How to get url from a string. (Part2) |
|
|
Hi,
Say i have a string like %%STRING containing "hello this is a url http://www.server.com enjoy...".
How could I extract the http://www.server.com from the string?
Thank you
Last edited by DW on Mon Jul 21, 2003 11:20 pm; edited 1 time in total |
|
| Back to top |
|
 |
Skit3000 Admin Team

Joined: 11 May 2002 Posts: 2166 Location: The Netherlands
|
Posted: Fri Jul 18, 2003 2:53 pm Post subject: |
|
|
Try this:
| Code: | %%input = "hello this is a url http://www.server.com enjoy..."
if @greater(@pos(http://,%%input),0)
%%output = @substr(%%input,@pos(http://,%%input),@len(%%input))
%%output = @substr(%%output,1,@pos(@chr(32),%%output))
end
info %%output |
You can change @chr(32) to every ASCII code you'll need as the end of the URL... _________________ [ Add autocomplete functionality to your VDS IDE windows! ]
Voor Nederlandse beginners met VDS: bekijk ook eens deze tutorial! |
|
| Back to top |
|
 |
DW Contributor

Joined: 21 Mar 2003 Posts: 175 Location: UK
|
Posted: Fri Jul 18, 2003 3:03 pm Post subject: |
|
|
Thank you, thats exactly what i needed.
THank you very much |
|
| Back to top |
|
 |
Skit3000 Admin Team

Joined: 11 May 2002 Posts: 2166 Location: The Netherlands
|
|
| Back to top |
|
 |
DW Contributor

Joined: 21 Mar 2003 Posts: 175 Location: UK
|
Posted: Mon Jul 21, 2003 11:23 pm Post subject: Part 2 |
|
|
Ok, I have been messing with that code you gave me but I have a problem.
The code you gave me works fine for line like;
something http://www.noserver.com something else.
but then i have some line like
something http://www.noserver.com
on these line, when links are clicked all i get it a message form windows telling me it cant open h.
what do i need to fix to make it work right? |
|
| Back to top |
|
 |
CodeScript Moderator Team

Joined: 08 Jun 2003 Posts: 1060 Location: India
|
Posted: Tue Jul 22, 2003 3:56 am Post subject: |
|
|
Just extend it a little.Check if the substr after http:// is www if so include else U know. That's all. _________________ Regards
- CodeScript
Give your application a professional look with the VDSGUI Extension |
|
| Back to top |
|
 |
Skit3000 Admin Team

Joined: 11 May 2002 Posts: 2166 Location: The Netherlands
|
Posted: Tue Jul 22, 2003 9:08 am Post subject: |
|
|
DW, that's because there isn't a @chr(32) after the http://. The next code checks if there is. If there isn't such a character, it will take the whole string which is left.
| Code: | %%input = "hello this is a url http://www.server.com"
if @greater(@pos(http://,%%input),0)
%%output = @substr(%%input,@pos(http://,%%input),@len(%%input))
if @greater(@pos(@chr(32),%%output),0)
%%output = @substr(%%output,1,@pos(@chr(32),%%output))
end
end
info %%output |
_________________ [ Add autocomplete functionality to your VDS IDE windows! ]
Voor Nederlandse beginners met VDS: bekijk ook eens deze tutorial! |
|
| Back to top |
|
 |
|