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.

How can 'string match' a *?

Old posts that have not been replied to for several years.
Locked
User avatar
Xpert
Halfop
Posts: 88
Joined: Mon Mar 08, 2004 7:03 am

How can 'string match' a *?

Post by Xpert »

How can i string match a *?
(ex: string match a '+' = [string match "*+*" "*$text*"])
Xpert.
User avatar
user
 
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

http://tcl.tk/man/tcl8.5/TclCmd/string.htm#M35
\x
Matches the single character x. This provides a way of avoiding the special interpretation of the characters *?[]\ in pattern
And since the parser itself performs backslash substitution, you'll need to escape the backslash to get one through to to the command.

Code: Select all

string match *\\** a*a
Have you ever read "The Manual"?
User avatar
Xpert
Halfop
Posts: 88
Joined: Mon Mar 08, 2004 7:03 am

Post by Xpert »

It works, thanks :P
Xpert.
User avatar
strikelight
Owner
Posts: 708
Joined: Mon Oct 07, 2002 10:39 am
Contact:

Post by strikelight »

user wrote:And since the parser itself performs backslash substitution, you'll need to escape the backslash to get one through to to the command.

Code: Select all

string match *\\** a*a
or alternatively, supply braces to eliminate the interpretter from implicitly interpretting special characters itself...

Code: Select all

string match {*\**} a*a
Locked