| View previous topic :: View next topic |
| Author |
Message |
-T- Voice
Joined: 08 Jul 2006 Posts: 4
|
Posted: Sat Jul 08, 2006 8:21 pm Post subject: Some help with regex |
|
|
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 |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Sun Jul 09, 2006 5:20 am Post subject: |
|
|
What is the problem? nobody's going to look it up for you. _________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
| Back to top |
|
 |
-T- Voice
Joined: 08 Jul 2006 Posts: 4
|
Posted: Sun Jul 09, 2006 11:30 am Post subject: |
|
|
| 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 |
|
| Back to top |
|
 |
Alchera Revered One

Joined: 11 Aug 2003 Posts: 3344 Location: Ballarat Victoria, Australia
|
Posted: Sun Jul 09, 2006 8:44 pm Post subject: |
|
|
| Code: | | if {regexp {.*(Wb|wB|wb|WB|GREETINGS|...)(!!| )?(\(|\*).*\)?(!!| )?(Wb|wB|wb|WB|FECKER|... remember this?|\|\|\|).*} $txt == 1} { ... } |
FYI _________________ Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
Last edited by Alchera on Sun Jul 09, 2006 10:38 pm; edited 1 time in total |
|
| Back to top |
|
 |
-T- Voice
Joined: 08 Jul 2006 Posts: 4
|
Posted: Sun Jul 09, 2006 9:18 pm Post subject: |
|
|
| hmm, I don't see a difference in that code and the one I have myself |
|
| Back to top |
|
 |
Alchera Revered One

Joined: 11 Aug 2003 Posts: 3344 Location: Ballarat Victoria, Australia
|
Posted: Sun Jul 09, 2006 10:38 pm Post subject: |
|
|
| -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 |
|
| Back to top |
|
 |
-T- Voice
Joined: 08 Jul 2006 Posts: 4
|
Posted: Mon Jul 10, 2006 10:02 am Post subject: |
|
|
| the pattern work in my mirc script. Unless the tcl regex engine is very different from the on used in mirc, it should work |
|
| Back to top |
|
 |
Alchera Revered One

Joined: 11 Aug 2003 Posts: 3344 Location: Ballarat Victoria, Australia
|
Posted: Mon Jul 10, 2006 10:19 am Post subject: |
|
|
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 |
|
| Back to top |
|
 |
rosc2112 Revered One

Joined: 19 Feb 2006 Posts: 1454 Location: Northeast Pennsylvania
|
Posted: Sun Jul 16, 2006 4:20 pm Post subject: |
|
|
| 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" |
|
| Back to top |
|
 |
metroid Owner
Joined: 16 Jun 2004 Posts: 771
|
Posted: Tue Jul 18, 2006 1:25 am Post subject: |
|
|
| Code: | % 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? |
|
| Back to top |
|
 |
rosc2112 Revered One

Joined: 19 Feb 2006 Posts: 1454 Location: Northeast Pennsylvania
|
Posted: Tue Jul 18, 2006 2:47 pm Post subject: |
|
|
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. |
|
| Back to top |
|
 |
|