proc fexpr str { set sciPat {[0-9](?:\.[0-9]*)?[eE][+-]?[0-9]+} set ranges [regexp -inline -indices -all $sciPat $str] set sciWords [lmap range $ranges { double [string range $str {*}$range] }] set betweenRanges [concat {*}[lmap range $ranges { lassign $range from to list [- $from 1] [+ $to 1] }]] set numPat {\.[0-9]+|[0-9]+(?:\.[0-9]*)?} set restWords [lmap {from to} "0 $betweenRanges end" { regsub -all $numPat [string range $str $from $to] double(&) }] foreach restWord $restWords sciWord $sciWords { append result $restWord $sciWord } expr $result }
© Wolf-Dieter Busch | Home | Sitemap | Urheber | A-Z