Skip to content
Permalink
Browse files

Backslash and groups rearrangement to regex based examples

  • Loading branch information
DelazJ authored and nyalldawson committed Aug 31, 2020
1 parent 97247ef commit 7c6ce37e2f07dd03d432c46c1c9a22d3b7202f6a
Showing with 7 additions and 3 deletions.
  1. +3 −2 resources/function_help/json/op_regex
  2. +4 −1 resources/function_help/json/regexp_replace
@@ -1,14 +1,15 @@
{
"name": "~",
"type": "operator",
"description": "Performs a regular expression match on a string value.",
"description": "Performs a regular expression match on a string value. Backslash characters must be double escaped (e.g., \"\\\\\\\\s\" to match a white space character).",
"arguments": [
{ "arg": "string", "description": "A string value" },
{ "arg": "regex", "description": "A regular expression. Slashes must be escaped, eg \\\\\\\\d." }
],
"examples": [
{ "expression":"'hello' ~ 'll'", "returns":"1"},
{ "expression":"'hello' ~ '^ll'", "returns":"0"},
{ "expression":"'hello' ~ 'llo$'", "returns":"1"}
{ "expression":"'hello' ~ 'llo$'", "returns":"1"},
{ "expression":"'abc123' ~ '\\\\\\\\d+'", "returns":"1"}
]
}
@@ -7,5 +7,8 @@
{"arg":"regex","description":"The regular expression to replace. Backslash characters must be double escaped (e.g., \"\\\\\\\\s\" to match a white space character)."},
{"arg":"replacement","description":"The string that will replace any matching occurrences of the supplied regular expression. Captured groups can be inserted into the replacement string using \\\\\\\\1, \\\\\\\\2, etc."}
],
"examples": [ { "expression":"regexp_replace('QGIS SHOULD ROCK','\\\\\\\\sSHOULD\\\\\\\\s',' DOES ')", "returns":"'QGIS DOES ROCK'"}]
"examples": [ { "expression":"regexp_replace('QGIS SHOULD ROCK','\\\\\\\\sSHOULD\\\\\\\\s',' DOES ')", "returns":"'QGIS DOES ROCK'"},
{ "expression":"regexp_replace('ABC123','\\\\\\\\d+','')", "returns":"'ABC'"},
{ "expression":"regexp_replace('my name is John','(.*) is (.*)','\\\\\\\\2 is \\\\\\\\1')", "returns":"'John is my name'"}
]
}

0 comments on commit 7c6ce37

Please sign in to comment.
You can’t perform that action at this time.