String matching with variable interpolation


I have the following:

field = "out"

But I would like to replace the “out” in <out>\s*(.*?)\s*</out> by field to make it dynamic.
How can i do that?

Thank you

In general you should not use Regex to handle HTML (XML) since Regex cannot parse HTML.

for this specif use:

julia> field = "out"

julia> rg = "<$field>\\s*(.*?)\\s*</$field>"

julia> match(Regex(rg), "<out>hello</out>")
RegexMatch("<out>hello</out>", 1="hello")

Thank you. The XML that I am trying to parse is in a weird format. I tried to use LightXML and EzXML but for this specific xml file it is not working.