Extract html tags with PCRE regex

Added by iNTERFACEWARE

How to extract the tags from a string of html, using PCRE regex with string.rxmatch()

Source Code
-- extract HTML tags from a string
local s = '<a href="#hello_world">Hello world link</a>'
local tags = ''
for k in s:rxmatch('(<[^>]+>)') do
trace(k)
tags = tags..k
end
trace(tags)
Description
How to extract the tags from a string of html, using PCRE regex with string.rxmatch()