Sun, 12 Aug 2012

I have written a function in XQuery where you can pass a key as an argument and retrieve that key's value, this function can be applied on unformatted text.

I have defined separators (of pairs) as a regular expression pattern that would match all whitespace in addition to commas:

[ \t\r\n,]+

And then I applied another regular expression to extract the key and value parts out of each pair:

([a-zA-Z0-9\.]+)=(\"?[a-zA-Z0-9\.\-\=]*\"?)

This pattern matches any alphanumeric keys (plus dots) and alphanumeric values (plus dots and dashes) that can be optionally quoted.

The full function is as foll...