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 

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

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Support & Releases
View previous topic :: View next topic  
Author Message
Pixelz
Voice


Joined: 15 Jun 2005
Posts: 24
Location: EFnet

PostPosted: Fri Oct 01, 2010 5:28 am    Post subject: substitute.tcl v1.0, sed-style text substitution (s/foo/bar) Reply with quote

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:
Quote:
Basic usage
<nick> Hello, World!
<nick> s/World/Everyone
<bot> Nick meant: "Hello, Everyone!"


Quote:
With : instead of /
<nick> Hello, World!
<nick> s:World:Everyone
<bot> Nick meant: "Hello, Everyone!"


Quote:
Removing text
<nick> Hello, World!
<nick> s/,/
<bot> Nick meant: "Hello World!"


Quote:
Substitutions can be stacked indefinately
<nick> Hello, World!
<nick> s/l/w/s/o/u
<bot> Nick meant: "Hewwu, Wurwd!"


Quote:
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!"


Quote:
Regular expression
<nick> Hello, World!
<nick> s/[A-Z]/Y
<bot> Nick meant: "Yello, Yorld!"


Quote:
More regular expression
<nick> Hello, World!
<nick> s/\S/x
<bot> Nick meant: "xxxxxx xxxxxx"


Quote:
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"


Quote:
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
_________________
Pixelz @ EFnet, freenode, QuakeNet, Undernet


Last edited by Pixelz on Tue Oct 05, 2010 12:01 pm; edited 1 time in total
Back to top
View user's profile Send private message
spithash
Master


Joined: 12 Jul 2007
Posts: 248
Location: Libera

PostPosted: Tue Oct 05, 2010 10:38 am    Post subject: Reply with quote

It's awesome, I use it all the time Very Happy
_________________
Libera ##rtlsdr & ##re - Nick: spithash
Click here for troll.tcl
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Support & Releases 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