You can use Mathematica's RegularExpression[] to find matches and replace them:
input = "
width=\"1234\" height=\"3456\"
width =\"1234\" height=\"3456\"
width = \"1234\" height =\"3456\"
width=\"1234\" height=\"3456\"
width=\"123s\" height=\"34z6\"
";
StringReplace[input,
RegularExpression[
"width\\s*=\\s*\"\\s*\\d*\\s*\"\\s*height\\s*=\\s*\"\\s*\\d*\\s*\"\
"] -> "class=\"responsive-image\""
]
This code returns the following string (note: since the last line was ill-formed, the replacement did not occur):
class="responsive-image"
class="responsive-image"
class="responsive-image"
class="responsive-image"
width="123s" height="34z6"
Breaking down the regular expression:
"width\\s*=\\s*\"\\s*\\d*\\s*\"\\s*height\\s*=\\s*\"\\s*\\d*\\s*\"\"
"width": starts with "width"
"\\s*": any number of whitespace (spaces, tabs, etc) characters
"=": equals sign
"\\s*": any number of whitespace (spaces, tabs, etc) characters
"\"": a quotation mark
"\\s*": any number of whitespace (spaces, tabs, etc) characters
"\\d*": any number of digit (0, 1, 2, ... 9) characters
and so on.
A word of caution though, if the height field is given first, this won't match. Also, this will replace all instances of the matches it finds. There may be parts of your HTML document that have width and height fields that you don't want changed to responsive-image.