How to find last occurrence of a number in a string using Ruby?
regex, ruby, string
Solution
There are answers how to do what you need
Also to find last occurence of number:
x = 'blah_blah.do.dah[4543]junk_junk'
x.rindex(/\d/)
Problem
Using Ruby... given the following string: ``` x = "blah_blah.do.dah[4543]junk_junk" ``` How do I remove all text after the last number/digit? I thought the easiest way to do this might be by finding the index of last occurrence and then removing everything after that index. However, I can't seem to figure out how to obtain that index. All my attempts at using regex have failed.