- Timestamp:
- Mar 27, 2011, 12:32:55 PM (13 years ago)
- Location:
- trunk/lang/tcl/scripts
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lang/tcl/scripts/objects/number/number.rp
r2154 r2156 103 103 104 104 import string {val {defunits ""}} { 105 puts "IMPORTING: $val (number with units $defunits)"106 105 if {[regexp {^([-+]?(?:[0-9]+\.|\.)?[0-9]+(?:[eE][-+]?[0-9]+)?)( *(?:[a-zA-Z]+[0-9]*)+(?:\/(?:[a-zA-Z]+[0-9]*)+)*)*$} $val match num units]} { 107 106 set sys [Rappture::Units::System::for $units] -
trunk/lang/tcl/scripts/validations/number.tcl
r2080 r2156 15 15 upvar $numvar num 16 16 upvar $unitsvar units 17 return [regexp {^([-+]?(?:[0-9]+\.|\.)?[0-9]+(?:[eE][-+]?[0-9]+)?)( *(?:[a-zA-Z]+[0-9]*)+(?:\/(?:[a-zA-Z]+[0-9]*)+)*)*$} $str match num units] 17 if {![regexp {^([-+]?(?:[0-9]+\.|\.)?[0-9]+(?:[eE][-+]?[0-9]+)?)( *[a-zA-Z/]?[a-zA-Z0-9/ \t]*)$} $str match num rest]} { 18 return 0 19 } 20 regsub -all {[ \t]+} $rest "" rest ;# strip out spaces from units 21 if {$rest eq ""} { 22 set units "" 23 } elseif {![regexp {^(/?[a-zA-Z]+[0-9]*)*$} $rest units]} { 24 return 0 ;# units failed to match 25 } 26 return 1; 18 27 } 19 28
Note: See TracChangeset
for help on using the changeset viewer.