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.

Some help with regex

Help for those learning Tcl or writing their own scripts.
Post Reply
-
-T-
Voice
Posts: 4
Joined: Sat Jul 08, 2006 8:18 pm

Some help with regex

Post by -T- »

This is my first go at tcl, so bear with me.

I'm having some problems with a regex function. If someone could take a look at it for me, I would be gratefull :)

The code is kind of long, so I won't paste it here. Take a look at pastebin for it :)

http://pastebin.ca/82855

Thanks again
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

What is the problem? nobody's going to look it up for you.
-
-T-
Voice
Posts: 4
Joined: Sat Jul 08, 2006 8:18 pm

Post by -T- »

there is a problem with the regex I think. It doesn't give me any errors, but it does not do anything even though I know the line of text matches the regex pattern
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Post by Alchera »

Code: Select all

if {regexp {.*(Wb|wB|wb|WB|GREETINGS|...)(!!| )?(\(|\*).*\)?(!!| )?(Wb|wB|wb|WB|FECKER|... remember this?|\|\|\|).*} $txt == 1} { ... }
FYI
Last edited by Alchera on Sun Jul 09, 2006 10:38 pm, edited 1 time in total.
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
-
-T-
Voice
Posts: 4
Joined: Sat Jul 08, 2006 8:18 pm

Post by -T- »

hmm, I don't see a difference in that code and the one I have myself
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Post by Alchera »

-T- wrote:hmm, I don't see a difference in that code and the one I have myself
There isn't. I pasted it for the information of others. I am not an expert regexp person but at first glance that looks like it would never function.
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
-
-T-
Voice
Posts: 4
Joined: Sat Jul 08, 2006 8:18 pm

Post by -T- »

the pattern work in my mirc script. Unless the tcl regex engine is very different from the on used in mirc, it should work
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Post by Alchera »

Tcl (Tool Command Language) is a different animal to any mIRC "script".

I suggest you read Tcl Built-In Commands - regexp manual page.
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
User avatar
rosc2112
Revered One
Posts: 1454
Joined: Sun Feb 19, 2006 8:36 pm
Location: Northeast Pennsylvania

Post by rosc2112 »

tcl's regex uses | to *concatenate* strings, not OR them..Maybe that's your problem? It also uses () to capture a segment for reporting... And there's also a -nocase option, so you don't need to search for various cases of "WB"
m
metroid
Owner
Posts: 771
Joined: Wed Jun 16, 2004 2:46 am

Post by metroid »

Code: Select all

% regexp {moo|m00|m0o} moo
1
% regexp {moo|m00|m0o} mo0
0
% regexp {moo|m00|m0o} m0o
1
% regexp {moo|m00|m0o} m00
1
are you sure about your previous statement rosc2112?
User avatar
rosc2112
Revered One
Posts: 1454
Joined: Sun Feb 19, 2006 8:36 pm
Location: Northeast Pennsylvania

Post by rosc2112 »

Just going by the docs and my own observations:

An ARE is one or more branches, separated by `|', matching anything that matches any of the branches.

A branch is zero or more constraints or quantified atoms, concatenated. It matches a match for the first, followed by a match for the second, etc; an empty branch matches the empty string.
Post Reply