How to get all digits from string regexp ruby
Without regex:
"Lorem 123 ipsum 456 879".delete('^0-9') #=>"123456879"
Just replace everything else.
result = subject.gsub(/[^\d]/, '')
Ref this
result = subject.gsub(/\D/, '')
"Lorem 123 ipsum 456 879".scan(/\d+/).join # => "123456879"