re = /\[\[Image:[^]]+link=[^]]+]]/
str = '$t = [[Image:United Kingdom images gbr image031 jpg.png|141px|link=HomePage|United Kingdom images gbr image031 jpg.png]]
[[Image:United Kingdom images gbr image030 jpg.png|141px|United Kingdom images gbr image030 jpg.png]]
[[Image:United Kingdom images gbr image031 jpg.png|141px|link=Contact|United Kingdom images gbr image031 jpg.png]];
<span class="United Kingdomtemplate_colour">Additional remarks</span><br> <br> Green sign with white and yellow text with blue plate with white text displaying that the indicated direction(s) lead to a motorway. [[Image:United Kingdom images gbr image031 jpg.png|141px|link=Home Page|United Kingdom images gbr image031 jpg.png]]<br>White sign with black text with blue plate with white text displaying that the indicated direction(s) lead to a motorway. [[Image:United Kingdom images gbr image046 jpg.png|292px|United Kingdom images gbr image046 jpg.png]]<br> <br> <span style="vertical-align: top;">White sign with black text with blue plate with white text displaying that the indicated direction(s) lead to a motorway. </span> [[Image:United Kingdom images gbr image2550 jpg.png|368px|United Kingdom images gbr image2550 jpg.png|link=Contact]]'
subst = '[noinclude]$0[/noinclude]'
result = str.gsub(re, subst)
# Print the result of the substitution
puts result
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Ruby, please visit: http://ruby-doc.org/core-2.2.0/Regexp.html