07-19-2023, 12:20 AM
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.
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.