forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


How to get url from a string. (Part2)

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help
View previous topic :: View next topic  
Author Message
DW
Contributor
Contributor


Joined: 21 Mar 2003
Posts: 175
Location: UK

PostPosted: Fri Jul 18, 2003 2:39 pm    Post subject: How to get url from a string. (Part2) Reply with quote

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
View user's profile Send private message
Skit3000
Admin Team


Joined: 11 May 2002
Posts: 2166
Location: The Netherlands

PostPosted: Fri Jul 18, 2003 2:53 pm    Post subject: Reply with quote

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
View user's profile Send private message
DW
Contributor
Contributor


Joined: 21 Mar 2003
Posts: 175
Location: UK

PostPosted: Fri Jul 18, 2003 3:03 pm    Post subject: Reply with quote

Thank you, thats exactly what i needed.
THank you very much
Back to top
View user's profile Send private message
Skit3000
Admin Team


Joined: 11 May 2002
Posts: 2166
Location: The Netherlands

PostPosted: Fri Jul 18, 2003 3:11 pm    Post subject: Reply with quote

No thanks, that's why I'm here for... Wink
_________________
[ Add autocomplete functionality to your VDS IDE windows! ]
Voor Nederlandse beginners met VDS: bekijk ook eens deze tutorial!
Back to top
View user's profile Send private message
DW
Contributor
Contributor


Joined: 21 Mar 2003
Posts: 175
Location: UK

PostPosted: Mon Jul 21, 2003 11:23 pm    Post subject: Part 2 Reply with quote

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
View user's profile Send private message
CodeScript
Moderator Team


Joined: 08 Jun 2003
Posts: 1060
Location: India

PostPosted: Tue Jul 22, 2003 3:56 am    Post subject: Reply with quote

Just extend it a little.Check if the substr after http:// is www if so include else U know. That's all.
_________________
Regards
- CodeScript
Arrow Give your application a professional look with the VDSGUI Extension
Back to top
View user's profile Send private message Visit poster's website
Skit3000
Admin Team


Joined: 11 May 2002
Posts: 2166
Location: The Netherlands

PostPosted: Tue Jul 22, 2003 9:08 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group