I've got the following text for example (stored as $test):
\u003c/p\u003e\n\u003cp\u003e\u003c/p\u003e\n\u003cimg src=\"/sites/mysite/SiteCollectionImages/banner.jpg\" alt=\"\" style=\"float:none;height: auto;width: auto\"/\u003e\n\u003cp\u003eMore Meat, Less Waste, Means More Value For Your Dollar.\u003c/p\u003e\n\u003cp\u003e\u003c/p\u003e\n\u003cp\u003eWhen substituting Emu meat in your recipes or planning your serving portions, keep in mind that low fat Emu meat will not shrink like other meats. You get more of what you pay for with no bones, exterior fat, or gristle. Emu meat is very shelf stable especially if vacuum packaged. Properly vacuum packaged meat will keep fresh in your refrigerator for up to 4 weeks, and up to 6-9 months in your freezer.\u003c/p\u003e\n\u003cp\u003e\u003c/p\u003e\n\u003cimg src=\"/sites/mysite/SiteCollectionImages/logo.jpg\" alt=\"\" style=\"float:none;height: auto;width: auto\"/\u003e\n\u003cp\u003e\u003c/p\u003e\n\u003cp\u003e\u003c/p\u003e\n\u003cp\u003e
I would like to update the bolded text in between img src=\" and \" (to something like /sites/newSite/newLibrary/originalFilename.v2.jpg)
How would I go about doing these replacements in Powershell using regex?
I've tried $test -replace '(?<=img src=\")(?<imgUrl>\")', ' ' to start and even that doesn't do any replacements for me.
Update
I was able to capture what I needed to replace by using $test -replace '(?<=img src=\\")(.+?)(?=\\")', '$1' (Thanks to @user1390638)
I wanted to apply a function to $1 before replacement so I had to do this to make it work:
[regex]::Replace($test, '(?<=img src=\\")(.+?)(?=\\")', {param($match) someFunction($match.Groups[1].Value) })