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 


Extract URL/email address from a string
Goto page 1, 2  Next
 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help
View previous topic :: View next topic  
Author Message
LiquidCode
Moderator Team


Joined: 05 Dec 2000
Posts: 1753
Location: Space and Time

PostPosted: Thu Mar 20, 2003 2:24 pm    Post subject: Extract URL/email address from a string Reply with quote

I'm having a wee bit of trouble. Smile I want to extract a URL or Email
address from a string no matter what is on front or behind the
address or URL, but, I'm not sure how to go about it. The URL can
start with ither http:// or www. I know to look for the @ in an address
but, I'm having brain trouble. Here is some example strings;

Got to this site! [b]http://www.cgsoft.us[/b]

or

Email me at [i]chris@cgsoft.us please.[/i]

or

Check this out www.cgsoft.us. It's a great site!

Yes the BBC code is to be there.

Thanks for any help,

_________________
Chris
Http://theblindhouse.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
ShinobiSoft
Professional Member
Professional Member


Joined: 06 Nov 2002
Posts: 790
Location: Knoxville, Tn

PostPosted: Thu Mar 20, 2003 2:35 pm    Post subject: Reply with quote

If you want the html tags, hyperlinks to another site or page :<a href="http://www.somesite.com">Some Site Name</a>

Hyperlinks to an email address: <a href="mailto://someone@some.com">Contact Me</a>

_________________
Bill Weckel
ShinobiSoft Software

"The way is known to all, but not all know it."
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
LiquidCode
Moderator Team


Joined: 05 Dec 2000
Posts: 1753
Location: Space and Time

PostPosted: Thu Mar 20, 2003 3:00 pm    Post subject: Reply with quote

I just want to take a normal string without HTML code and extract
and email or URL. The string may or may not have BBCode in it
but it does not have HTML code. Know what I mean? Smile

_________________
Chris
Http://theblindhouse.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
ShinobiSoft
Professional Member
Professional Member


Joined: 06 Nov 2002
Posts: 790
Location: Knoxville, Tn

PostPosted: Thu Mar 20, 2003 3:06 pm    Post subject: Reply with quote

gotcha Wink

Code:


%%source = 1234567 zippy do da http://www.some.com some more jibberish

%P = @pos(http://,%%source)
if @greater(%%source,0)
  %P = @sum(%P,7)
  %%sub = @substr(%%source,%P,@len(%%source))
  %%P2 = @pos(@chr(32),%%sub)
  if @greater(%%P2,0)
    %%url = @substr(%%source,%P,@pred(@sum(%P,@pred(%%P2))))
  end
end



Is that what ya meant? Smile


EDIT - Extracts text after "http://" up to the next space. No longer pseudo code. Smile

_________________
Bill Weckel
ShinobiSoft Software

"The way is known to all, but not all know it."


Last edited by ShinobiSoft on Thu Mar 20, 2003 3:50 pm; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
FreezingFire
Admin Team


Joined: 23 Jun 2002
Posts: 3508

PostPosted: Thu Mar 20, 2003 3:32 pm    Post subject: Reply with quote

When using that code I get <http://www.some.com s>.
_________________
FreezingFire
VDSWORLD.com
Site Admin Team
Back to top
View user's profile Send private message Visit poster's website
ShinobiSoft
Professional Member
Professional Member


Joined: 06 Nov 2002
Posts: 790
Location: Knoxville, Tn

PostPosted: Thu Mar 20, 2003 3:41 pm    Post subject: Reply with quote

The above code is from off the top of my head. That's what "Pseudo Code"
stands for. But how are you getting the "<" and ">" from that string ?

_________________
Bill Weckel
ShinobiSoft Software

"The way is known to all, but not all know it."
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
LiquidCode
Moderator Team


Joined: 05 Dec 2000
Posts: 1753
Location: Space and Time

PostPosted: Thu Mar 20, 2003 3:43 pm    Post subject: Reply with quote

Kind of...I think I found a work around....Thanks for the help.
_________________
Chris
Http://theblindhouse.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
FreezingFire
Admin Team


Joined: 23 Jun 2002
Posts: 3508

PostPosted: Thu Mar 20, 2003 3:44 pm    Post subject: Reply with quote

I'm not, perhaps they are confusing. I put them there to show no spaces. Wink
_________________
FreezingFire
VDSWORLD.com
Site Admin Team
Back to top
View user's profile Send private message Visit poster's website
ShinobiSoft
Professional Member
Professional Member


Joined: 06 Nov 2002
Posts: 790
Location: Knoxville, Tn

PostPosted: Thu Mar 20, 2003 3:51 pm    Post subject: Reply with quote

I've edited my code post to correct the code. It now extracts the text as
specified in the EDIT note. Smile

_________________
Bill Weckel
ShinobiSoft Software

"The way is known to all, but not all know it."
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
FreezingFire
Admin Team


Joined: 23 Jun 2002
Posts: 3508

PostPosted: Thu Mar 20, 2003 3:55 pm    Post subject: Reply with quote

I'm still not advanced at strings, etc. and I thought the following would
work, but why not?

Code:
%%input = Take a look at http://www.vdsworld.com/ for many extensions and articles.
%%pos1 = @pos(http://,%%input)
%%SubStr = @substr(%%input,%%pos1,@len(%%input))
%%pos2 = @pos(@chr(32),%%SubStr))
%%URL = @substr(%%SubStr,0,%%pos2)
info %%URL

_________________
FreezingFire
VDSWORLD.com
Site Admin Team
Back to top
View user's profile Send private message Visit poster's website
ShinobiSoft
Professional Member
Professional Member


Joined: 06 Nov 2002
Posts: 790
Location: Knoxville, Tn

PostPosted: Thu Mar 20, 2003 4:04 pm    Post subject: Reply with quote

This line:
Code:

%%pos2 = @pos(@chr(32),%%SubStr))


It has an extra ")" on the end of it .Smile

_________________
Bill Weckel
ShinobiSoft Software

"The way is known to all, but not all know it."
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
ShinobiSoft
Professional Member
Professional Member


Joined: 06 Nov 2002
Posts: 790
Location: Knoxville, Tn

PostPosted: Thu Mar 20, 2003 4:06 pm    Post subject: Reply with quote

Oops.

And this line:
Code:

%%URL = @substr(%%SubStr,0,%%pos2)


should be:
Code:

%%URL = @substr(%%SubStr,1,@pred(%%pos2))


strings are counted from 1 in VDS not zero like in C/C++ Smile

_________________
Bill Weckel
ShinobiSoft Software

"The way is known to all, but not all know it."
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
FreezingFire
Admin Team


Joined: 23 Jun 2002
Posts: 3508

PostPosted: Thu Mar 20, 2003 4:10 pm    Post subject: Reply with quote

Thanks for your comments. Here's one that works too:

Code:
%%input = Take a look at http://www.vdsworld.com/ for many extensions and articles.
%%pos1 = @pos(http://,%%input)
%%SubStr = @substr(%%input,%%pos1,@len(%%input))
%%pos2 = @pos(@chr(32),%%SubStr)
%%URL = @substr(%%SubStr,1,%%pos2)
info %%URL

_________________
FreezingFire
VDSWORLD.com
Site Admin Team
Back to top
View user's profile Send private message Visit poster's website
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Thu Mar 20, 2003 4:40 pm    Post subject: Reply with quote

Hey FF,

Ya might wanna try my code checker when ya have a lot
of "( )" in your code. If there's any mismatched, it tells ya
which line it's on, how many are missing, and whether it's
left or right brackets. Wink

Also checks IF/END, REPEAT/UNTIL, and WHILE/WEND
matches, subprocedure nesting, and finds variables.

http://www.vdsworld.com/forum/viewtopic.php?t=1322

Cheers, Mac Smile

_________________
VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
Back to top
View user's profile Send private message Send e-mail
FreezingFire
Admin Team


Joined: 23 Jun 2002
Posts: 3508

PostPosted: Thu Mar 20, 2003 5:04 pm    Post subject: Reply with quote

Thanks, Mac! I think this will help a lot in my future coding! Very Happy
_________________
FreezingFire
VDSWORLD.com
Site Admin Team
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
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