Finding elements in a string (SOLVED)

In one of my scripts, I download some HTML data and divide it into sections. Each section has the same format, just with different values (username, tags, etc.). I need to further divide each section into its values to store them in a table, but each one is a different length, so I can’t just hardcode an amount to trim them by. I’ve been thinking about this for some time, and I’m out of ideas. Since it might be brought up, yes, I do have DefString added to the project. I would put an example of the data I’m working with, but it’s pretty long.

Maybe you need an XML parser.

Are you not in control of the data so that maybe you can transform it before you download it?

Have you looked into Lua patterns (similar but simpler than regular expressions)? Perhaps string.match() or string.gmatch() could work for you?

I think it would be helpful if you share at least a smaller sample of the data. Or a URL so we can see for ourselves.

You may want to check out the Lua patterns manual.

Seems like patterns is the way to go on this one. Thanks for the tip!

2 Likes