There's been a few too many political posts lately. Not wanting to disappoint my (most probable) only reader, Tim, I've decided to get back on topic.
I will be using Lua to work on an upcoming project.
The project in question is a simple XML parser, which I will need later.
(Well, not need exactly. But it would be very helpful to have).
Here is a small snippet of code for the purpose of getting used to pattern matching (No, I'm not a World of Warcracker; but that is a very good reference).
function main()
local string = "
local match = string.gsub(string, "</?%a+>", "")
print(match) -- prints tagvalue
end
main()
Very simple stuff - here's the deal:
- Look in string for matches for start and end tags.
- Replace these tags with nothing.
- Print out the value contained within the pair of tags.
That will pretty much handle (with some modification of course) getting a value from within a specified pair of tags. But of course, I have to consider more advanced tags such as those with attributes.
But I will be working on this stuff shortly.
Featured image courtesy of hub19 (CC-BY-NC-SA)
No comments:
Post a Comment