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.
Old posts that have not been replied to for several years.
ranny
Halfop
Posts: 49 Joined: Wed Jun 22, 2005 2:00 pm
Location: switzerland
Post
by ranny » Mon Aug 15, 2005 3:17 pm
Hello,
I try regexp.
I've two problems
Code: Select all
( ranny ): .tcl regexp {\bworld\b} "the world is good"
<eggy> Tcl: 0
Why not matching?
This code
Code: Select all
( ranny ): .tcl regexp {l(?=o)} color
<eggy> Tcl: 1
it's ok
but
Code: Select all
( ranny ): .tcl regexp {(?<=l)o} color
<eggy> Tcl error: couldn't compile regular expression pattern: quantifier operand invalid
??
thx
demond
Revered One
Posts: 3073 Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:
Post
by demond » Mon Aug 15, 2005 3:38 pm
\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
ranny
Halfop
Posts: 49 Joined: Wed Jun 22, 2005 2:00 pm
Location: switzerland
Post
by ranny » Mon Aug 15, 2005 4:57 pm
ok,
You can just tell me how is $string for match this code please(an example)
thx
demond
Revered One
Posts: 3073 Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:
Post
by demond » Mon Aug 15, 2005 5:01 pm
what do you want to match? describe with your own words, not with RE
ranny
Halfop
Posts: 49 Joined: Wed Jun 22, 2005 2:00 pm
Location: switzerland
Post
by ranny » Tue Aug 16, 2005 2:07 am
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
demond
Revered One
Posts: 3073 Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:
Post
by demond » Tue Aug 16, 2005 2:38 am
ranny
Halfop
Posts: 49 Joined: Wed Jun 22, 2005 2:00 pm
Location: switzerland
Post
by ranny » Tue Aug 16, 2005 7:23 am
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.
greenbear
Owner
Posts: 733 Joined: Mon Sep 24, 2001 8:00 pm
Location: Norway
Post
by greenbear » Tue Aug 16, 2005 9:37 am
did you try seperating them using space. eg. \s
demond
Revered One
Posts: 3073 Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:
Post
by demond » Tue Aug 16, 2005 11:54 am
Code: Select all
[regexp {(^|\s+)word($|\s+)} $str] && [regexp {(^|\s+)is($|\s+)} $str]
ranny
Halfop
Posts: 49 Joined: Wed Jun 22, 2005 2:00 pm
Location: switzerland
Post
by ranny » Tue Aug 16, 2005 11:59 am
ok
Code: Select all
regexp {(^word\s|\sword\s|\sword$)} $string
it works for one word.
1/there is simpler?
2/ if i want match two words
Code: Select all
regexp {(^word1\s|\sword1\s) (\sword2\s|\sword2$)} $string
don't match?
I want match the string with "word1 word2" or "word2 word1"
thx
demond
Revered One
Posts: 3073 Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:
Post
by demond » Tue Aug 16, 2005 12:14 pm
I gave you the solution, did you bother to test it at all?
ranny
Halfop
Posts: 49 Joined: Wed Jun 22, 2005 2:00 pm
Location: switzerland
Post
by ranny » Tue Aug 16, 2005 5:00 pm
erf,
sorry demond but we've post at the same time.Thx
ranny
Halfop
Posts: 49 Joined: Wed Jun 22, 2005 2:00 pm
Location: switzerland
Post
by ranny » Thu Aug 18, 2005 7:15 am
Hello, another question,
If i want match "WOrd" or "word" or "worD"...
How to do it?
Thx
ranny
Halfop
Posts: 49 Joined: Wed Jun 22, 2005 2:00 pm
Location: switzerland
Post
by ranny » Thu Aug 18, 2005 1:23 pm
Ahhhh,
It's what I had done but with an error
Thx