jeudi 26 juillet 2018

Regular expression for repeating pattern

I have text with the pattern: pagelimit=50&filtercolumn=Datacenter&filtervalue=abfg1&filtercolumn=MachineType&filtervalue=fg&filtercolumn=GPG&filtervalue=IPMI

I want to get back

  1. filtercolumn=Datacenter&filtervalue=abfg1
  2. filtercolumn=MachineType&filtervalue=fg
  3. filtercolumn=GPG&filtervalue=IPMI

There may be an unlimited amount of these.

I have tried a few things. I'm currently trying something like this:

(?:((filtercolumn=.*&filtervalue=.*)+),?)

But of course it doesn't work. I get:

  1. filtercolumn=Datacenter&filtervalue=vin1&filtercolumn=MachineType&filtervalue=sd&filtercolumn=APC&filtervalue=IPMI
  2. filtercolumn=Datacenter&filtervalue=vin1&filtercolumn=MachineType&filtervalue=sd&filtercolumn=APC&filtervalue=IPMI

Language is Golang

Aucun commentaire:

Enregistrer un commentaire