Skip to content

Instantly share code, notes, and snippets.

@rknuu
Last active August 29, 2015 14:21
Show Gist options
  • Save rknuu/b945aa2df96daea9b2e1 to your computer and use it in GitHub Desktop.
Save rknuu/b945aa2df96daea9b2e1 to your computer and use it in GitHub Desktop.
seriously complicated regular expression in XQuery
(: taken from http://markmail.org/message/5p3uespuxk4ew7fa :)
let $regexp := '(\{)|(\})|(\[)|(\])|(:)|(,)|(true)|(false)|(null)|(\s+)|("([^"\\]|\\"|\\\\|\\/|\\b|\\f|\\n|\\r|\\t|\\u[A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9])*")|(-?(0|[1-9][0-9]*)(\.[0-9]+)?([eE][+-]?[0-9]+)?)'
return
let $json := '{
"firstName": "John",
"lastName": "Smith",
"address": {
"streetAddress": "21 2nd Street",
"city": "New York",
"state": "NY",
"postalCode": 10021
},
"phoneNumbers": [
"212 732-1234",
"646 123-4567"
]
}'
return analyze-string($json, $regexp)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment