Created
May 6, 2013 16:39
-
-
Save ncimino/5526288 to your computer and use it in GitHub Desktop.
Multi character (string) split in Tcl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# mcsplit -- | |
# | |
# Splits a string based using another string | |
# | |
# Arguments: | |
# str string to split into pieces | |
# splitStr substring | |
# mc magic character that must not exist in the orignal string. | |
# Defaults to the NULL character. Must be a single character. | |
# Results: | |
# Returns a list of strings | |
# | |
proc mcsplit "str splitStr {mc {\x00}}" { | |
return [split [string map [list $splitStr $mc] $str] $mc] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment