I have a string
path = "MT_Store_0 /47/47/47/opt/47/47/47/data/47/47/47/FCS/47/47/47/oOvt4wCtSuODh8r9RuQT3w"
I want to remove the part of string from first /47
using gsub
.
path.gsub! '/47/', '/'
Expected output:
"MT_Store_0 "
Actual output:
"MT_Store_0 /47/opt/47/data/47/FCS/47/oOvt4wCtSuODh8r9RuQT3w"
In the regex,
\/47.*
matches/47
and any characters following it.Or, you can write the regex using
%r
to avoid escaping the forward slashes: