| View previous topic :: View next topic |
| Author |
Message |
ache Voice
Joined: 14 Oct 2005 Posts: 14
|
Posted: Tue Nov 08, 2005 7:22 am Post subject: regular expression? or similar function |
|
|
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 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 |
|
 |
Alchera Revered One

Joined: 11 Aug 2003 Posts: 3344 Location: Ballarat Victoria, Australia
|
|
| Back to top |
|
 |
]Kami[ Owner

Joined: 24 Jul 2003 Posts: 590 Location: Slovenia
|
Posted: Tue Nov 08, 2005 2:48 pm Post subject: |
|
|
Check tutorial for parasin web pages here _________________ Slovene Eggdrop Page |
|
| Back to top |
|
 |
demond Revered One

Joined: 12 Jun 2004 Posts: 3073 Location: San Francisco, CA
|
Posted: Wed Nov 09, 2005 1:12 am Post subject: |
|
|
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 |
|
 |
|