simple regex to splice out text in ruby
- by user141146
I'm using ruby and I want to splice out a piece of a string that matches a regex (I think this is relatively easy, but I'm having difficulty)
I have several thousand strings that look like this (to varying degrees)
my_string = "adfa <b>weru</b> orua fklajdfqwieru ofaslkdfj alrjeowur woer woeriuwe <img src=\"/images/abcde_111-222-333/111-222-333.xml/blahblahblah.jpg\" />"
I would like to splice out the /111-222-333.xml (the value of this changes from string to string, but suffice it to say is that I want to remove the piece between 2 forward slashes that contains something.xml.
my hope was to find a match like this
my_match = my_string.match(/\/.+?\.xml\//)
but this actually captures "/b> orua fklajdfqwieru ofaslkdfj alrjeowur woer woeriuwe <img src=\"/images/abcde_111-222-333/111-222-333.xml/"
I assumed that .+? would match what I am looking for, but it seems like it starts with the first forward slash that it finds (even though it's non-greedy) and then expands forward to the ".xml").
Any thoughts on what I'm doing wrong?
TKS!!