Version 0 of Extract Numbers From a String

Updated 2022-10-01 12:36:15 by WJG

WJG (01/10/22) A quick snippet on extracting a list of numbers from a string.

proc extracNumbers {str} {
        set res ""
        foreach c [split $str ""] {
                if { [string is integer $c] } {
                        set a 1
                        append res $c
                } elseif { $c == "," || $c == "." } {
                        if {$a} { append res $c }
                } else {
                        set a 0
                        append res " "
                }
        }
        return [string trim $res]
}