In general you should not use Regex to handle HTML (XML) since Regex cannot parse HTML.
for this specif use:
julia> field = "out"
"out"
julia> rg = "<$field>\\s*(.*?)\\s*</$field>"
"<out>\\s*(.*?)\\s*</out>"
julia> match(Regex(rg), "<out>hello</out>")
RegexMatch("<out>hello</out>", 1="hello")