Skip to content

Commit

Permalink
refactor and deprecate CutZeros
Browse files Browse the repository at this point in the history
  • Loading branch information
jreidinger committed Jan 30, 2015
1 parent ff94b91 commit d04192f
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions library/types/src/modules/String.rb
Expand Up @@ -326,12 +326,11 @@ def CutBlanks(input)
#
# @param [String] input number that might contain leadig zero
# @return [String] that has leading zeros removed
# @deprecated if conversion to integer is needed in decimal use {::String#to_i}
def CutZeros(input)
return "" if input.nil? || Ops.less_than(Builtins.size(input), 1)
return input if !Builtins.regexpmatch(input, "^0.*")
output = Builtins.regexpsub(input, "^0+(.*)$", "\\1")
return "0" if Ops.less_than(Builtins.size(output), 1)
output
return "" if input.nil?

input.sub(/\A0*([0-9])/, "\\1")
end

# Repeat a string
Expand Down

0 comments on commit d04192f

Please sign in to comment.