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.

help with regexp

Old posts that have not been replied to for several years.
Locked
User avatar
Dedan
Master
Posts: 260
Joined: Wed Jul 09, 2003 10:50 pm
Location: Memphis

help with regexp

Post by Dedan »

I have tried many different combinations,
but i can not find the right ones.

the snipplet is suppost to count the codes

Code: Select all


  set codes(found) [regexp -all {(002) (003) (037)} $text]


thanks for any help given
I once was an intelligent young man, now i am old and i can not remember who i was.
User avatar
user
 
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

Code: Select all

regexp -all {\002|\003|\037} $text
or

Code: Select all

regexp -all {[\002\003\037]} $text
Last edited by user on Wed Aug 13, 2003 6:09 am, edited 1 time in total.
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

instead of \003 it should be \003[0-9]{0,2}(,[0-9]{0,2})? I think due the *variables* it has like: 2,4 or 2, etc. A simple test should reveal If I'm right or wrong.
Once the game is over, the king and the pawn go back in the same box.
User avatar
user
 
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

caesar wrote:instead of \003 it should be \003[0-9]{0,2}(,[0-9]{0,2})? I think due the *variables* it has like: 2,4 or 2, etc. A simple test should reveal If I'm right or wrong.
I don't think he cares what color's used :P
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Oups, yes, he only wants to count 'em :)
Once the game is over, the king and the pawn go back in the same box.
User avatar
Dedan
Master
Posts: 260
Joined: Wed Jul 09, 2003 10:50 pm
Location: Memphis

Post by Dedan »

how would i look for spaces?

i tried:

Code: Select all


  set spaces(found) [regexp -all {" "} $text]
  puthelp "PRIVMSG $chan :spaces(found) is $spaces(found)"

thanks for the "codes" help, it works like a charm
I once was an intelligent young man, now i am old and i can not remember who i was.
User avatar
user
 
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

Dedan wrote:

Code: Select all

set spaces(found) [regexp -all {" "} $text]
The quotes between the braces are taken litterally, so your rule would match quote-space-quote. Get rid of the quotes and it'll work just fine :)
User avatar
Dedan
Master
Posts: 260
Joined: Wed Jul 09, 2003 10:50 pm
Location: Memphis

Post by Dedan »

works great, thanks.

1 more question

how can i get " [ ] " into a channel msg?

Code: Select all


puthelp "PRIVMSG $chan :[exp/too many codes]"

puthelp "PRIVMSG $chan :{[exp/too many codes]}"

puthelp "PRIVMSG $chan :"[exp/too many codes]""

all 3 do not work

[06:51] Tcl error [protect:channel]: invalid command name "exp/too"

[06:53] Tcl error [protect:channel]: extra characters after close-quote
I once was an intelligent young man, now i am old and i can not remember who i was.
User avatar
user
 
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

\[\]
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Only the [ must be .. umm.. forgot the word :) basicaly it should be \[]
Once the game is over, the king and the pawn go back in the same box.
User avatar
user
 
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

caesar wrote:Only the [ must be .. umm.. forgot the word :) basicaly it should be \[]
Yes, but escaping the "]" doesn't hurt and will prevent confusing behaviour if you have an unterminated "[" some place before the unescaped "]"
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Umm.. if you are carefully then there should not be a problem, but basicaly yes, is nice to *escape* them..
Once the game is over, the king and the pawn go back in the same box.
User avatar
Dedan
Master
Posts: 260
Joined: Wed Jul 09, 2003 10:50 pm
Location: Memphis

Post by Dedan »

Thanks for all the Help
I once was an intelligent young man, now i am old and i can not remember who i was.
Locked