Skip to content

Commit

Permalink
Backslash and groups rearrangement to regex based examples
Browse files Browse the repository at this point in the history
  • Loading branch information
DelazJ authored and nyalldawson committed Aug 31, 2020
1 parent 97247ef commit 7c6ce37
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 3 additions & 2 deletions resources/function_help/json/op_regex
@@ -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"}
]
}
5 changes: 4 additions & 1 deletion resources/function_help/json/regexp_replace
Expand Up @@ -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.