Version 0 of String Difference

Updated 2011-12-13 11:47:42 by WJG

WJG (12/12/11) This simple proc arose out of the need to create text line references such as T08n0224_p0425a18(02)-T08n0224_p0425a19(00) in a more compact form, i.e T08n0224_p0425a18(02)-9(00).

#---------------
# Compare str2 to str1 until a mismatch is found. At that point return remainder of str2.
#---------------
# Arguments
#
# Returns
proc string_diff {str1 str2} {
        
        for {set i 0} {$i < [string length $str1]} {incr i} {
                if {  [string index $str2 $i] != [string index $str1 $i] } {
                        return [string range $str2 $i end]
                        } 
                }
        return [string range $str2 $i end]
}