Is there a short way to extract a number like 1 or 10 from a string like Level 1 or Level 10? I think Ruby made something besides using regular expressions.
ruby
I don't think there's a function that's made separately. I used gsub to exclude non-numeric characters as regular expressions.
print 'level 1'.gsub(/[^0-9]/,'')
© 2024 OneMinuteCode. All rights reserved.