-5

I have following string

2014-04-29T06-19-20_17368f93ce02e18f278ae22d248e7d0692db3f54d2409_1088x288.mp4.uploaded

I want to remove the last .uploaded word from this whole string .

How can I do this?

2 Answers2

1

Use .sub to replace .uploaded with nothing:

str='2014-04-29T06-19-20_17368f93ce02e18f278ae22d248e7d0692db3f54d2409_1088x288.mp4.uploaded'
str.sub! '.uploaded', ''
0

I found answer of this:

"2014-04-29T06-19-20_17368f93ce02e18f278ae22d248e7d0692db3f54d2409_1088x288.mp4.uploaded".split(".uploaded").first

It delete the last word from the given string

o/p:

2014-04-29T06-19-20_17368f93ce02e18f278ae22d248e7d0692db3f54d2409_1088x288.mp4