Folks, one thing I find I have to do more often lately is parse repeated
keywork+value pairs, and I can't figure out how to craft the right regex
pattern for this sort of thing (assuming regex can do it). I have something
like this sample:

 

%KEY1, value1 %KEY2,value2   %KEY3, %NOTE,This is a note %NAME, Fred Knuckle

 

The red chars are the keywords, each keyword is followed by an optional
value. Spaces can appear randomly. I'm hoping there's some way of parsing
out these pieces:

 

"KEY1"

"value1"

"KEY2"

"value2"

"KEY3"

""

"NOTE"

"This is a note"

"NAME"

"Fred Knuckle"

 

Sorry for the boring looking question, but if I can find a way of parsing
"repeated patterns" like my sample then it will solve a general problem
that's been irritating me for ages, and the regex technique might be of
general use to others.

 

Cheers,

Greg

Reply via email to