egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

regular expression? or similar function

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
ache
Voice


Joined: 14 Oct 2005
Posts: 14

PostPosted: Tue Nov 08, 2005 7:22 am    Post subject: regular expression? or similar function Reply with quote

Hello again.
I need some help with getting some text from a string.
Donīt know if regexpīs is the way to do it, anyways.
I have this line:
Code:

caching and translation of results, and an option to find similar pages.<br><font color=#008000>www.<b>google</b>.com/ -  3k -  7 nov 2005 - </font><nobr>  <a class=fl href="http://72.14.207.104/search?q=cache:zhool8dxBV4J:www.google.com/+google&hl=sv">Cachad</a> - <a class=fl href="/search?hl=sv&lr=&q=related:www.google.com/">Liknande&nbsp;sidor</a></nobr></font> <blockquote class=g><p class=g><a href="http://www.google.com/search">www.google.com/search</a><br><font size=-1><s


what i want is to get these two things from the string into some varialbles:
Code:

$desc
caching and translation of results, and an option to find similar pages.
$url
www.google.com


As you might guess iīm working on a google search script and i only want the description of the page and the actual url so i figure that i only need to go through this line:
Code:

caching and translation of results, and an option to find similar pages.<br><font color=#008000>www.<b>google</b>.com/ -  3k -  7 nov 2005 - </font>

I thought of matching everything before the <BR> tag and place it in $desc
and to get all text between <font color=#008000> and </font> into $url then remove the <b>and </b> tags.
problem is i donīt know anything about regular expressions so i have no idea on how to get on with this.

any help is much appriciated.

thanks
Back to top
View user's profile Send private message
Alchera
Revered One


Joined: 11 Aug 2003
Posts: 3344
Location: Ballarat Victoria, Australia

PostPosted: Tue Nov 08, 2005 9:14 am    Post subject: Reply with quote

regexp manual page

regsub manual page
_________________
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
Back to top
View user's profile Send private message Visit poster's website
]Kami[
Owner


Joined: 24 Jul 2003
Posts: 590
Location: Slovenia

PostPosted: Tue Nov 08, 2005 2:48 pm    Post subject: Reply with quote

Check tutorial for parasin web pages here
_________________
Slovene Eggdrop Page
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
demond
Revered One


Joined: 12 Jun 2004
Posts: 3073
Location: San Francisco, CA

PostPosted: Wed Nov 09, 2005 1:12 am    Post subject: Reply with quote

this is an excerpt from rssnews.tcl, showing how to extract text between tags:
Code:

   regexp {(?i)<title.*?>(.*?)</title>}  $item -> title
   regexp {(?i)<link.*?>(.*?)</link}     $item -> link
   regexp {(?i)<desc.*?>(.*?)</desc.*?>} $item -> descr

_________________
connection, sharing, dcc problems? click <here>
before asking for scripting help, read <this>
use [code] tag when posting logs, code
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
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


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber