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.

substitute.tcl v1.0, sed-style text substitution (s/foo/bar)

Support & discussion of released scripts, and announcements of new releases.
Post Reply
User avatar
Pixelz
Voice
Posts: 24
Joined: Wed Jun 15, 2005 9:37 am
Location: EFnet

substitute.tcl v1.0, sed-style text substitution (s/foo/bar)

Post by Pixelz »

This script provides sed style text subsitution, with full regular expression support. Use ".chanset #chan +substitute" to enable the script in a channel.

Notes:
Flags (i.e. global, case-insensitive) aren't supported directly in the syntax, however Tcl metasyntax can still be used. Expressions default to global/all, case-sensitive. Note that it's not possible to turn on or off global matching via metasyntax, this is because of a limitation in Tcl.

Usage examples:
Basic usage
<nick> Hello, World!
<nick> s/World/Everyone
<bot> Nick meant: "Hello, Everyone!"
With : instead of /
<nick> Hello, World!
<nick> s:World:Everyone
<bot> Nick meant: "Hello, Everyone!"
Removing text
<nick> Hello, World!
<nick> s/,/
<bot> Nick meant: "Hello World!"
Substitutions can be stacked indefinately
<nick> Hello, World!
<nick> s/l/w/s/o/u
<bot> Nick meant: "Hewwu, Wurwd!"
You can keep stacking over multiple messages
<nick> Hello, World!
<nick> s/World/Everyone
<bot> Nick meant: "Hello, Everyone!"
<nick> s/Everyone/Friday
<bot> Nick meant: "Hello, Friday!"
Regular expression
<nick> Hello, World!
<nick> s/[A-Z]/Y
<bot> Nick meant: "Yello, Yorld!"
More regular expression
<nick> Hello, World!
<nick> s/\S/x
<bot> Nick meant: "xxxxxx xxxxxx"
Metasyntax in action, turning on case insensitive matching:
<nick> Aaa Bbb
<nick> s/(?i)a/x/s/(?i)b/y
<bot> Nick meant: "xxx yyy"
Substitution guru:
<nick> :p
<nick> s/:/abc/s/p/defg/s/[ce]/^/s/d/o/s/a/\/s:g:/:s/b/(/s/f/)
<bot> Nick meant: "\(^o^)/"
Download: substitute-1.0.tcl
Last edited by Pixelz on Tue Oct 05, 2010 12:01 pm, edited 1 time in total.
Pixelz @ EFnet, freenode, QuakeNet, Undernet
User avatar
spithash
Master
Posts: 249
Joined: Thu Jul 12, 2007 9:21 am
Location: Libera
Contact:

Post by spithash »

It's awesome, I use it all the time :D
Libera ##rtlsdr & ##re - Nick: spithash
Click here for troll.tcl
Post Reply