2
Am I trying to replace inside a tag? EX:
mystr = '<html><head></head><body><p>Aqui meu texto</p></body></html>'
mystr = mystr:gsub('<.+>', '')
print(mystr)
I’d like you to return:
Aqui meu texto
But nothing comes back.
2
Am I trying to replace inside a tag? EX:
mystr = '<html><head></head><body><p>Aqui meu texto</p></body></html>'
mystr = mystr:gsub('<.+>', '')
print(mystr)
I’d like you to return:
Aqui meu texto
But nothing comes back.
4
The problem is that '<.+>'
house all the string and the gsub
then removes all content.
If you want to extract a text, use string.match
and catches:
print(mystr:match('<p>(.-)</p>'))
If you want to replace the text, use
mystr = mystr:gsub('<p>.-</p>','<p>Eis o novo texto</p>',1)
Browser other questions tagged lua
You are not signed in. Login or sign up in order to post.
With mystr:gsub('<.->', ''), I was able to do what I was trying to do.
– Gabriel Sales
@Gabrielsales, ah, now I understand: you want remove all tags.
– lhf