We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Yeah, I didn't use regex. I created my own "Tag" class with a map for attributes and a vector of sub "Tag"s. Similar to yours. I just can't traverse in reverse, which isn't needed. I then split the string up by writing an "explode" method that splits the string a vector of attributes and a string for the name. So, no regex needed. I find this much simpler.
The trickiest part for me was recursively adding the sub Tags properly. I could have done it in a much less elegant manner, with a lot more lines of code, but it was fun. The way I organized it makes searching much easier and cleaner.
I had it working perfectly, assuming "tag4~v2" would match the first tag with the name "tag4" and search for a v2 attribute, but that's not what they wanted. I'll have to read back to see if this was specified, but I found out through a failing test 4 I believe. So, I had to go back and rework all of my sub tag adding logic.
Curious - I ended up including my own "base" tag, just so I had a root tag to reference. Did you do anything like that?
Either way, I'll join the people complaining as well.
Attribute Parser
You are viewing a single comment's thread. Return to all comments →
Yeah, I didn't use regex. I created my own "Tag" class with a map for attributes and a vector of sub "Tag"s. Similar to yours. I just can't traverse in reverse, which isn't needed. I then split the string up by writing an "explode" method that splits the string a vector of attributes and a string for the name. So, no regex needed. I find this much simpler.
The trickiest part for me was recursively adding the sub Tags properly. I could have done it in a much less elegant manner, with a lot more lines of code, but it was fun. The way I organized it makes searching much easier and cleaner.
I had it working perfectly, assuming "tag4~v2" would match the first tag with the name "tag4" and search for a v2 attribute, but that's not what they wanted. I'll have to read back to see if this was specified, but I found out through a failing test 4 I believe. So, I had to go back and rework all of my sub tag adding logic.
Curious - I ended up including my own "base" tag, just so I had a root tag to reference. Did you do anything like that?
Either way, I'll join the people complaining as well.