Janet
Janet

Reputation: 61

Regex to remove quotes from img tag

I need to remove all quotes from an image tag found within lots of other text. For example, I want to make

<img src="folder/image.gif" target="_blank" />

into

<img src=folder/image.gif target=_blank />

I'm using vb, and need to use a regEx specifically for the img tag and not use replace. The img tag can be in a block of other text, so I need to use regEx to search for the <img and then within that until I meet a /> I need to remove all quotes. Is that better? Thanks so much for your patience - I had an emergency at work today.

Upvotes: 1

Views: 795

Answers (5)

Janet
Janet

Reputation: 61

This seems to work if anyone else needs it: (?i)(?<=]*)["]

Upvotes: 0

Jordan
Jordan

Reputation: 5058

What language are you using? You might be able to get away with a string replace function. PHP has a nice one str_replace http://php.net/manual/en/function.str-replace.php

Upvotes: 1

AdamH
AdamH

Reputation: 2201

Assuming you've read in the string in javascript, all you need to do is str.replace("\"", ""). Is that what you're after?

Upvotes: 0

Josh M.
Josh M.

Reputation: 27801

In C#:

theUrl.Replace("\"", "");

Upvotes: 1

Donut
Donut

Reputation: 112825

If all you want to do is replace quotes, you don't even need a regex -- your language's string replacement function will suffice. In C#, this would be String.Replace:

string noQuotes = myString.Replace('\"', '');

What language are you using?

Upvotes: 3

Related Questions