| View previous topic :: View next topic |
| Author |
Message |
X-Ception Voice
Joined: 20 May 2005 Posts: 37 Location: Earth
|
Posted: Sun Oct 30, 2005 11:20 am Post subject: Regex output |
|
|
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  |
|
| Back to top |
|
 |
De Kus Revered One

Joined: 15 Dec 2002 Posts: 1361 Location: Germany
|
Posted: Sun Oct 30, 2005 11:26 am Post subject: |
|
|
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 |
|
 |
X-Ception Voice
Joined: 20 May 2005 Posts: 37 Location: Earth
|
Posted: Sun Oct 30, 2005 11:46 am Post subject: |
|
|
| 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 |
|
 |
De Kus Revered One

Joined: 15 Dec 2002 Posts: 1361 Location: Germany
|
Posted: Sun Oct 30, 2005 12:11 pm Post subject: |
|
|
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 |
|
 |
X-Ception Voice
Joined: 20 May 2005 Posts: 37 Location: Earth
|
Posted: Sun Oct 30, 2005 12:14 pm Post subject: |
|
|
| 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 |
|
 |
De Kus Revered One

Joined: 15 Dec 2002 Posts: 1361 Location: Germany
|
Posted: Sun Oct 30, 2005 12:15 pm Post subject: |
|
|
| 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 . Be more detailed to get a more detailed example .
| 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 . Just a little note, when you use "" instead of {} you will need to use ". \\\\." . _________________ 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 |
|
 |
X-Ception Voice
Joined: 20 May 2005 Posts: 37 Location: Earth
|
Posted: Sun Oct 30, 2005 12:23 pm Post subject: |
|
|
| 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 . Be more detailed to get a more detailed example .
| 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 . Just a little note, when you use "" instead of {} you will need to use ". \\\\." . |
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 |
|
 |
X-Ception Voice
Joined: 20 May 2005 Posts: 37 Location: Earth
|
Posted: Sun Oct 30, 2005 1:16 pm Post subject: |
|
|
Thank you, works perfectly now.  |
|
| Back to top |
|
 |
X-Ception Voice
Joined: 20 May 2005 Posts: 37 Location: Earth
|
Posted: Sun Oct 30, 2005 3:38 pm Post subject: |
|
|
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 any ideas ? |
|
| Back to top |
|
 |
De Kus Revered One

Joined: 15 Dec 2002 Posts: 1361 Location: Germany
|
Posted: Sun Oct 30, 2005 5:31 pm Post subject: |
|
|
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 |
|
 |
X-Ception Voice
Joined: 20 May 2005 Posts: 37 Location: Earth
|
Posted: Sun Oct 30, 2005 6:25 pm Post subject: |
|
|
| 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 |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Sun Oct 30, 2005 8:11 pm Post subject: |
|
|
| 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 |
|
 |
X-Ception Voice
Joined: 20 May 2005 Posts: 37 Location: Earth
|
Posted: Sun Oct 30, 2005 10:05 pm Post subject: |
|
|
well that's what i was looking at too, but i think ive goofed up somewhere else int he script could it be possibly this bit since it was mentioned earlier as being incorrect
| Code: |
set text [lindex [split $text " "] 0]
|
|
|
| Back to top |
|
 |
X-Ception Voice
Joined: 20 May 2005 Posts: 37 Location: Earth
|
Posted: Sun Oct 30, 2005 10:06 pm Post subject: |
|
|
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 |
|
 |
De Kus Revered One

Joined: 15 Dec 2002 Posts: 1361 Location: Germany
|
Posted: Sun Oct 30, 2005 10:50 pm Post subject: |
|
|
| X-Ception wrote: | well that's what i was looking at too, but i think ive goofed up somewhere else int he script 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 . that might be the first time you could consider using regsub .
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 |
|
 |
|