mercredi 6 mai 2015

Regex capture groups in any order

I need to capture attribute values from the string like this:

att_name1=value1|att_name2=value2|att_name3=value3

Attributes can be in any order. Number of attributes is about 50.

I'm aware about lookarounds with which I can match the string. And I wrote the regex that can capture values in particular order:

"^att1=(?\w+)\|att2=(?\w+)\|att3=(?\w+)$

Is it a way to handle any attribute order?

Aucun commentaire:

Enregistrer un commentaire