This example will find all code tags and pass the lang attribute's value and the code block's content to the block:
```ruby
output = r.gsub(/
(.*?)<\/code[\.|\:]?\1?>/m) do
lang, text = $1, $2
html = "" + text + " "
end.to_html
```
The block's return value will replace the found tag.