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 

Regex output

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
X-Ception
Voice


Joined: 20 May 2005
Posts: 37
Location: Earth

PostPosted: Sun Oct 30, 2005 11:20 am    Post subject: Regex output Reply with quote

Hi,
i have a script pre made that relays information from one channel to another, but i require the outputted information to be pre regex formatted. So that its put in normal at channel A and the output in channel B is regex.

anyone got any ideas ? been looking for a while cant seem to get it right Sad
Back to top
View user's profile Send private message Visit poster's website
De Kus
Revered One


Joined: 15 Dec 2002
Posts: 1361
Location: Germany

PostPosted: Sun Oct 30, 2005 11:26 am    Post subject: Reply with quote

How is an output supposed to become a regex? Either a string is an regular expression, or it just a string.
_________________
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
Back to top
View user's profile Send private message MSN Messenger
X-Ception
Voice


Joined: 20 May 2005
Posts: 37
Location: Earth

PostPosted: Sun Oct 30, 2005 11:46 am    Post subject: Reply with quote

De Kus wrote:
How is an output supposed to become a regex? Either a string is an regular expression, or it just a string.

well its just url conversion so im guessing just a string im very unfamiliar with regex to be honest ( working on that tho ) an example output would be

Channel A relays goto irc.somewhere.net
Channel B outputs goto irc\.somwehere\.net

least i think thats right again im still reading up on regex :/

from my knowledge it needs to work the same way unrealircd's does
Back to top
View user's profile Send private message Visit poster's website
De Kus
Revered One


Joined: 15 Dec 2002
Posts: 1361
Location: Germany

PostPosted: Sun Oct 30, 2005 12:11 pm    Post subject: Reply with quote

what about string map?
[string map {. \\.} $string]
should be just fine
_________________
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
Back to top
View user's profile Send private message MSN Messenger
X-Ception
Voice


Joined: 20 May 2005
Posts: 37
Location: Earth

PostPosted: Sun Oct 30, 2005 12:14 pm    Post subject: Reply with quote

De Kus wrote:
what about string map?
[string map {. \\.} $string]
should be just fine

would you mind giving an example on usage ? as i say its new to me :/ dont want to screw it up
Back to top
View user's profile Send private message Visit poster's website
De Kus
Revered One


Joined: 15 Dec 2002
Posts: 1361
Location: Germany

PostPosted: Sun Oct 30, 2005 12:15 pm    Post subject: Reply with quote

X-Ception wrote:
would you mind giving an example on usage ? as i say its new to me :/ dont want to screw it up

open up your eyes, I gave you an example Razz. Be more detailed to get a more detailed example Razz.
Code:
% string map {. \\.} "goto irc.somewhere.net"
goto irc\.somewhere\.net
You can try it on your own tcl shell if you dont trust me Very Happy. Just a little note, when you use "" instead of {} you will need to use ". \\\\." Razz.
_________________
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
Back to top
View user's profile Send private message MSN Messenger
X-Ception
Voice


Joined: 20 May 2005
Posts: 37
Location: Earth

PostPosted: Sun Oct 30, 2005 12:23 pm    Post subject: Reply with quote

De Kus wrote:
X-Ception wrote:
would you mind giving an example on usage ? as i say its new to me :/ dont want to screw it up

open up your eyes, I gave you an example Razz. Be more detailed to get a more detailed example Razz.
Code:
% string map {. \\.} "goto irc.somewhere.net"
goto irc\.somewhere\.net
You can try it on your own tcl shell if you dont trust me Very Happy. Just a little note, when you use "" instead of {} you will need to use ". \\\\." Razz.

lol thank you and aplogies :/

appreciated i'll have a play now.

and no not that i dont trust you or anything like that at all more a case of its very new to me and im not exactly the greatest scripter going as is, so do just need longer to run these things thru my brain.
Back to top
View user's profile Send private message Visit poster's website
X-Ception
Voice


Joined: 20 May 2005
Posts: 37
Location: Earth

PostPosted: Sun Oct 30, 2005 1:16 pm    Post subject: Reply with quote

Thank you, works perfectly now. Smile
Back to top
View user's profile Send private message Visit poster's website
X-Ception
Voice


Joined: 20 May 2005
Posts: 37
Location: Earth

PostPosted: Sun Oct 30, 2005 3:38 pm    Post subject: Reply with quote

Ok i have one more tiny issue, ive got everything working perfect till a space comes into play so far i have :
Code:
    putserv "PRIVMSG #channel :  [string map {. \\. : \\: / \\/ exe \exe$ * \\* bat \bat$ jpg \jpg$ mpg \mpg$}  $text]"

which works fine till a space comes into it so then it only echoes the first char, normally without replacement i would use
Code:
[lrange $text 0 end]

to echo the entire sentance, sadly this doesnt work and still picks up the first char Sad any ideas ?
Back to top
View user's profile Send private message Visit poster's website
De Kus
Revered One


Joined: 15 Dec 2002
Posts: 1361
Location: Germany

PostPosted: Sun Oct 30, 2005 5:31 pm    Post subject: Reply with quote

do you want to strip leading and trailing spaces?!
then you should have scrolled down the string manual some more, string trim will delete them.
just: [string trim $text]

PS: dont use list commands on strings. list commands are intented to be used with proper lists only (made by split, list or lappend).
_________________
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
Back to top
View user's profile Send private message MSN Messenger
X-Ception
Voice


Joined: 20 May 2005
Posts: 37
Location: Earth

PostPosted: Sun Oct 30, 2005 6:25 pm    Post subject: Reply with quote

De Kus wrote:
do you want to strip leading and trailing spaces?!
then you should have scrolled down the string manual some more, string trim will delete them.
just: [string trim $text]

PS: dont use list commands on strings. list commands are intented to be used with proper lists only (made by split, list or lappend).

Yep thats ok, but still only outs puts the first word in the relay :/ i thought parhaps [string wordstart $text wordend ] might do it but alas still only one word and a fair few hundred rehases trying to rack my braina round it
Back to top
View user's profile Send private message Visit poster's website
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Sun Oct 30, 2005 8:11 pm    Post subject: Reply with quote

X-Ception wrote:
... i thought parhaps [string wordstart $text wordend ] ...

You mean:
Code:
string range $text 0 end

_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
Back to top
View user's profile Send private message Visit poster's website
X-Ception
Voice


Joined: 20 May 2005
Posts: 37
Location: Earth

PostPosted: Sun Oct 30, 2005 10:05 pm    Post subject: Reply with quote

well that's what i was looking at too, but i think ive goofed up somewhere else int he script Neutral could it be possibly this bit since it was mentioned earlier as being incorrect
Code:

  set text [lindex [split $text " "] 0]
Back to top
View user's profile Send private message Visit poster's website
X-Ception
Voice


Joined: 20 May 2005
Posts: 37
Location: Earth

PostPosted: Sun Oct 30, 2005 10:06 pm    Post subject: Reply with quote

and the corrected line for relay is:
Code:
    putserv "PRIVMSG <chan> : \037Text:\037 [string map {. \\. : \\: / \\/ exe \exe$ * \\* bat \bat$ jpg \jpg$ mpg \mpg$} [string range $text 0 end] ]"
Back to top
View user's profile Send private message Visit poster's website
De Kus
Revered One


Joined: 15 Dec 2002
Posts: 1361
Location: Germany

PostPosted: Sun Oct 30, 2005 10:50 pm    Post subject: Reply with quote

X-Ception wrote:
well that's what i was looking at too, but i think ive goofed up somewhere else int he script Neutral could it be possibly this bit since it was mentioned earlier as being incorrect
Code:

  set text [lindex [split $text " "] 0]

this line is the reason for your "one word" problem.
btw... after that line $text is a string again. drop that lindex thing. oh, btw. if you want to elimiate multiple white spaces... this wont be enough Very Happy. that might be the first time you could consider using regsub Very Happy.
ex.: regsub -all {\s+} $text { } text
_________________
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
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