Skip to content

Instantly share code, notes, and snippets.

@ncimino
Created May 6, 2013 16:39
Show Gist options
  • Save ncimino/5526288 to your computer and use it in GitHub Desktop.
Save ncimino/5526288 to your computer and use it in GitHub Desktop.
Multi character (string) split in Tcl
# 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