ruby - How do I use a regular expression to match a number as an integer? -
when match number using regular expression string:
?> 'testingsubject2981'.match /\d+$/ => #<matchdata "2981">
is somehow possible number integer without to_i
s?
the issue regular expressions work on strings, not on other data types.
a regex has patterns match numbers, still find characters represent number, not binary values we'd use math. once engine returns matches, they're still characters, have use to_i
convert them binary representations.
mmm-kay?
Comments
Post a Comment