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 

regexp question

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


Joined: 26 Oct 2005
Posts: 9

PostPosted: Sun Aug 31, 2008 1:11 pm    Post subject: regexp question Reply with quote

Can someone help me how to skip word like I'll . it's , she's ... in $text? thanks

while {[regexp -indices -start $pos {[^[:punct:]\s]+} $text match]} {
lappend words $match
lassign $match -> pos
incr pos
}
Back to top
View user's profile Send private message
speechles
Revered One


Joined: 26 Aug 2006
Posts: 1398
Location: emerald triangle, california (coastal redwoods)

PostPosted: Sun Aug 31, 2008 4:06 pm    Post subject: Reply with quote

Code:
<speechles> .tcl set a "I'll . it's , she's ..."
<bot> Tcl: I'll . it's , she's ...
<speechles> .tcl set b [string map {"." "" "?" "" "," ""} $a]
<bot> Tcl: I'll  it's  she's
<speechles> .tcl set c [join [split $b]]
<bot> Tcl: I'll it's she's

Like that? Part c, the join and split is there to eliminate over spaced fields and return to the string to nomal single spaces.
_________________
speechles' eggdrop tcl archive
Back to top
View user's profile Send private message
garung
Voice


Joined: 26 Oct 2005
Posts: 9

PostPosted: Sun Aug 31, 2008 5:12 pm    Post subject: Reply with quote

speechless, it's tnot that, i mean skip these words(he's she's it's) so that they dont replace them with asterisks
Back to top
View user's profile Send private message
speechles
Revered One


Joined: 26 Aug 2006
Posts: 1398
Location: emerald triangle, california (coastal redwoods)

PostPosted: Sun Aug 31, 2008 7:02 pm    Post subject: Reply with quote

garung wrote:
speechless, it's tnot that, i mean skip these words(he's she's it's) so that they dont replace them with asterisks

Code:
<speechles> .tcl set a [asterize "this, is a word. this is a question?"]
<bot> Tcl: ****, ** * ****. **** ** * ********?
<speechles> .tcl set a [asterize "he's got this. she's got that. you've got those."]
<bot> Tcl: **'* *** ****. ***'* *** ****. ***'** *** *****.


Code:
proc asterize {text} {
   set asterisktext ""
   foreach word [split $text] {
      set asteriskword ""
      foreach char [split $word ""] {
         if {[string match *$char* "`~!@#$%^&()\[\]\{\}:;'\"<>\?,."]} {
            append asteriskword $char
         } else {
            append asteriskword "*"
         }
      }
      append asterisktext "$asteriskword "
   }
   return [string trim $asterisktext]
}

You mean like this?
_________________
speechles' eggdrop tcl archive
Back to top
View user's profile Send private message
garung
Voice


Joined: 26 Oct 2005
Posts: 9

PostPosted: Sun Aug 31, 2008 11:03 pm    Post subject: Reply with quote

You're so cool! thanks speechles Smile
Back to top
View user's profile Send private message
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