regular expression for finding and replacing variable URL strings in XML

jepot

New Member
I'm having some difficulty figuring out a regular expression for stripping part of the string within a particular XML tag and replacing it. I have a number of URL paths with variable parts, so I need to find everything between a certain string and the last slash in the URL. For example, I might have tags and URLS that look like this:\[quote\] \[code\]<bpoc:resourceMetadataLoc>http://app01/media/images/I//1951-1960_Embark_Object_Photos/1957.59.jpg</bpoc:resourceMetadataLoc>\[/code\]\[/quote\]or\[quote\] \[code\]<bpoc:resourceMetadataLoc>http://app01/media/images/CONTEMPORARY/1986-2005/1991.2.jpg</bpoc:resourceMetadataLoc>\[/code\]\[/quote\]The output should look like\[quote\] \[code\]<bpoc:resourceMetadataLoc>http://app01/media/Previews/1957.59.jpg</bpoc:resourceMetadataLoc>\[/code\]\[/quote\]This is about as far as I got, but it captures the last slash in the string, and not the second-to-last slash:\[quote\] \[code\](<bpoc:resourceMetadataLoc>http://app01/media/images)+(.*[/])\[/code\]\[/quote\]That regex will capture the following:\[quote\] \[code\]<bpoc:resourceMetadataLoc>http://app01/media/images/I//1951-1960_Embark_Object_Photos/1957.59.jpg</\[/code\]\[/quote\]What would I need to add to the regex to exclude the \[code\]</bpoc:resourceMetadataLoc>\[/code\] bit from the query and then capture everything prior to the last slash in the URL?
 
Back
Top