This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

regular expression? or similar function

Help for those learning Tcl or writing their own scripts.
Post Reply
a
ache
Voice
Posts: 14
Joined: Fri Oct 14, 2005 7:27 am

regular expression? or similar function

Post by ache »

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: Select all

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: Select all

$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: Select all

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
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Post by Alchera »

Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
User avatar
]Kami[
Owner
Posts: 590
Joined: Thu Jul 24, 2003 2:59 pm
Location: Slovenia
Contact:

Post by ]Kami[ »

Check tutorial for parasin web pages here
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

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

Code: Select all

	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: Select all

 tag when posting logs, code
Post Reply