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 

regexp problem
Goto page 1, 2  Next
 
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
ranny
Halfop


Joined: 22 Jun 2005
Posts: 49
Location: switzerland

PostPosted: Mon Aug 15, 2005 3:17 pm    Post subject: regexp problem Reply with quote

Hello,
I try regexp.
I've two problems
Code:

( ranny ): .tcl regexp {\bworld\b} "the world is good"
<eggy> Tcl: 0

Why not matching?

This code
Code:
( ranny ):  .tcl regexp {l(?=o)} color
<eggy> Tcl: 1

it's ok
but
Code:

( ranny ): .tcl regexp {(?<=l)o} color
<eggy> Tcl error: couldn't compile regular expression pattern: quantifier operand invalid
??

thx
Back to top
View user's profile Send private message
demond
Revered One


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

PostPosted: Mon Aug 15, 2005 3:38 pm    Post subject: Reply with quote

\b is RE escape for backspace and you don't have backspace

(?=re) is positive lookahead, valid in AREs (advanced REs) only, and I very much doubt it's that what you had in mind

(?<= is RE error
Back to top
View user's profile Send private message Visit poster's website
ranny
Halfop


Joined: 22 Jun 2005
Posts: 49
Location: switzerland

PostPosted: Mon Aug 15, 2005 4:57 pm    Post subject: Reply with quote

ok,

You can just tell me how is $string for match this code please(an example)
Code:
regexp {\bworld\b} $string

thx
Back to top
View user's profile Send private message
demond
Revered One


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

PostPosted: Mon Aug 15, 2005 5:01 pm    Post subject: Reply with quote

what do you want to match? describe with your own words, not with RE
Back to top
View user's profile Send private message Visit poster's website
ranny
Halfop


Joined: 22 Jun 2005
Posts: 49
Location: switzerland

PostPosted: Tue Aug 16, 2005 2:07 am    Post subject: Reply with quote

Yes, i try with an example.

I want to match a string(with regexp) who contains the words "word" and "is".
In fact i don't want to match a word who contains the words.
"the word is simple"==>match
"this word "==>not match
"F**** is a badword"==>not match
......

thx
Back to top
View user's profile Send private message
demond
Revered One


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

PostPosted: Tue Aug 16, 2005 2:38 am    Post subject: Reply with quote

Code:

regexp word.*is $str
Back to top
View user's profile Send private message Visit poster's website
ranny
Halfop


Joined: 22 Jun 2005
Posts: 49
Location: switzerland

PostPosted: Tue Aug 16, 2005 7:23 am    Post subject: Reply with quote

no demond,

it's not that.
I want that the code matches all string with "word" and "is". But it shouldn't match the words who contains "word" and "is"(badword,this,history...don't have matches).
I thought that to use \b was a solution to limit the word but it's not that.

If you can help me.
Back to top
View user's profile Send private message
greenbear
Owner


Joined: 24 Sep 2001
Posts: 733
Location: Norway

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

did you try seperating them using space. eg. \s
Back to top
View user's profile Send private message Send e-mail
demond
Revered One


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

PostPosted: Tue Aug 16, 2005 11:54 am    Post subject: Reply with quote

Code:

[regexp {(^|\s+)word($|\s+)} $str] && [regexp {(^|\s+)is($|\s+)} $str]
Back to top
View user's profile Send private message Visit poster's website
ranny
Halfop


Joined: 22 Jun 2005
Posts: 49
Location: switzerland

PostPosted: Tue Aug 16, 2005 11:59 am    Post subject: Reply with quote

ok
Code:
regexp {(^word\s|\sword\s|\sword$)} $string

it works for one word.

1/there is simpler?

2/ if i want match two words
Code:
regexp {(^word1\s|\sword1\s) (\sword2\s|\sword2$)} $string

don't match?
I want match the string with "word1 word2" or "word2 word1"
thx
Back to top
View user's profile Send private message
demond
Revered One


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

PostPosted: Tue Aug 16, 2005 12:14 pm    Post subject: Reply with quote

I gave you the solution, did you bother to test it at all?
Back to top
View user's profile Send private message Visit poster's website
ranny
Halfop


Joined: 22 Jun 2005
Posts: 49
Location: switzerland

PostPosted: Tue Aug 16, 2005 5:00 pm    Post subject: Reply with quote

erf,

sorry demond but we've post at the same time.Thx
Back to top
View user's profile Send private message
ranny
Halfop


Joined: 22 Jun 2005
Posts: 49
Location: switzerland

PostPosted: Thu Aug 18, 2005 7:15 am    Post subject: Reply with quote

Hello, another question,
If i want match "WOrd" or "word" or "worD"...
How to do it?
Thx
Back to top
View user's profile Send private message
greenbear
Owner


Joined: 24 Sep 2001
Posts: 733
Location: Norway

PostPosted: Thu Aug 18, 2005 10:52 am    Post subject: Reply with quote

Code:
regexp -nocase { .....
Back to top
View user's profile Send private message Send e-mail
ranny
Halfop


Joined: 22 Jun 2005
Posts: 49
Location: switzerland

PostPosted: Thu Aug 18, 2005 1:23 pm    Post subject: Reply with quote

Ahhhh,
It's what I had done but with an error Embarassed
Thx
Back to top
View user's profile Send private message
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
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


Forum hosting provided by Reverse.net

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