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 

another regexp problem

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    egghelp.org community Forum Index -> Archive
View previous topic :: View next topic  
Author Message
eiSi
Halfop


Joined: 07 Mar 2002
Posts: 70

PostPosted: Tue Aug 16, 2005 6:56 am    Post subject: another regexp problem Reply with quote

hi there!

I started to concern myself with regexp now, and I already have a problem:

the string ($text):
Code:
<a href=/item.html?witem=647>Destiny</a>


my code:
Code:
regexp {\.html\?witem=([0-9]*?)\>} $text result


I know there's anything wrong with it, but I don't know what.

the match I get is: .html?witem=647>
but I want to get: 647

thanks for any help!

regards,
eiSi
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger
avilon
Halfop


Joined: 13 Jul 2004
Posts: 64
Location: Germany

PostPosted: Tue Aug 16, 2005 9:15 am    Post subject: Reply with quote

Code:
scan $text "<a href=/item.html?witem=%d>*</a>" digit

647 is stored in $digit.
Back to top
View user's profile Send private message
eiSi
Halfop


Joined: 07 Mar 2002
Posts: 70

PostPosted: Tue Aug 16, 2005 9:34 am    Post subject: Reply with quote

ah thanks a lot!

but I'm interested, what was wrong with my regexp?
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger
greenbear
Owner


Joined: 24 Sep 2001
Posts: 733
Location: Norway

PostPosted: Tue Aug 16, 2005 9:51 am    Post subject: Reply with quote

There's nothing wrong with your regexp, you just missed the 2nd var at the end.
Regexp writes the entire matching pattern to the first var.

So this should work:
Code:
regexp {\.html\?witem=([0-9]*?)\>} $text garbage result


You dont have to make it this complex, though. You could probably have gotten away with doing something like this:
Code:
regexp {witem=(.*?)>} $text . digit
Back to top
View user's profile Send private message Send e-mail
eiSi
Halfop


Joined: 07 Mar 2002
Posts: 70

PostPosted: Tue Aug 16, 2005 10:08 am    Post subject: Reply with quote

ah alright, thanks for your help!
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    egghelp.org community Forum Index -> Archive 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