I’m working on a script for work to extract data from an old template engine schema:
[%price%] { $54.99 } [%/price%] [%model%] { WRT54G } [%/model%] [%brand%]{ LINKSYS } [%/brand%]
everything within the [% %] is the key, and everything in the { } is the value. Using Python and regex, I was able to get this far: (?<=[%)(?P\w*?)(?=\%])
which returns [‘price’, ‘model’, ‘brand’]
I’m just having a problem getting it match the bracket data as a value
just for grins:
output:
Note I did just enough regex to get the matches to show up, it’s not even bounded at the end for the close brace. Use at your own risk.