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 

string containing * (asterisk)

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


Joined: 05 Mar 2009
Posts: 48

PostPosted: Sun Mar 03, 2019 8:34 pm    Post subject: string containing * (asterisk) Reply with quote

Hi there

Am trying to detect strings with * (asterisks) in them to do (something)...

Have tied:

Code:

if {[string match "{*\*}*" $tt]}
and
if {[string match "*\**" $tt]}


...but no luck. Any help would be appreciated!
Cheers
Back to top
View user's profile Send private message Visit poster's website
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3584
Location: Mint Factory

PostPosted: Mon Mar 04, 2019 1:57 am    Post subject: Reply with quote

Code:

% set text "* bla bla * bla"
* foo
% string first * $text
0
% set text "bla bla * bla"
bla bla * bla
% string first * $text
8

as you can see it returns the position of first match.
_________________
I tawt I taw a puddy tat!
Back to top
View user's profile Send private message
NewzNZ
Halfop


Joined: 05 Mar 2009
Posts: 48

PostPosted: Mon Mar 04, 2019 2:05 am    Post subject: Reply with quote

Thanks for the reply...will give it a go!
Back to top
View user's profile Send private message Visit poster's website
willyw
Revered One


Joined: 15 Jan 2009
Posts: 1046

PostPosted: Mon Mar 04, 2019 11:23 am    Post subject: Re: string containing * (asterisk) Reply with quote

NewzNZ wrote:

...

Am trying to detect strings with * (asterisks) in them to do (something)...

Have tied:

Code:

if {[string match "{*\*}*" $tt]}
...



Playing in partyline, I first did:
Code:

.set testtext "bla bla * bla"


Next:
Code:

<myhandle> .tcl string match {*\**} $testtext
<botnick> Tcl: 1


Compared to yours, all I did was move the last asterisk to be inside the curly braces.

For the heck of it, I then played with it some more:

Code:

<myhandle> .tcl string match {*\* *} $testtext
<botnick> Tcl: 1
<myhandle> .tcl string match {* \* *} $testtext
<botnick> Tcl: 1
<myhandle> .tcl string match {* \*  *} $testtext
<botnick> Tcl: 0
<myhandle> .tcl string match {* \* *} $testtext
<botnick> Tcl: 1


I hope this helps.
_________________
For a fun (and popular) Trivia game, visit us at: irc.librairc.net #science-fiction . Over 300K Q & A to play in BogusTrivia !
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