Displaying page
of
pages;
Items to
Title |
Test
Details
Get key value pairs separated by colon in a comma separated string
|
Expression |
(?<key>[^\s]+(\s\w)*)(?=([\s]*:[\s]*))\2(?<=\2)(?<value>\b[^,:]+\b)
|
Description |
Sometimes I want to store some key value mapped data in xml or text file, and then retrieve them into hashtable in program. Authough this can be done by split the string by comma and colon, and then trim the white space, I think regular expression should be easier. Note, the key must be single word or single white space separated words, and value can be any none colon or comma charactor serial.
|
Matches |
" name a : hongfei jiang , gender: male, age :545 "
|
Non-Matches |
name a : hongfei jiang
|
Author |
Rating:
Not yet rated.
jianghongfei
|
Displaying page
of
pages;
Items to