Very new to Ruby,
file_path = "/.../datasources/xml/data.txt"
How can I find the value between the last two forward slashes? In this case that value is ‘xml’…I can’t use absolute positioning because the number of ‘/’ will vary as will the text , but the value I need is always in between the last two /
I could only find examples on how to find a specific word in a string, but in this case I don’t know the value of the word so those examples did not help.
file_path.split("/").fetch(-2)you said you’re sure it’s always between two last slashes. this splits your string into an array over slashes and then gets the second last element.