Skip to content

Commit 7c6ce37

Browse files
DelazJnyalldawson
authored andcommittedAug 31, 2020
Backslash and groups rearrangement to regex based examples
fix qgis/QGIS-Documentation#5760
1 parent 97247ef commit 7c6ce37

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed
 

‎resources/function_help/json/op_regex

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
{
22
"name": "~",
33
"type": "operator",
4-
"description": "Performs a regular expression match on a string value.",
4+
"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).",
55
"arguments": [
66
{ "arg": "string", "description": "A string value" },
77
{ "arg": "regex", "description": "A regular expression. Slashes must be escaped, eg \\\\\\\\d." }
88
],
99
"examples": [
1010
{ "expression":"'hello' ~ 'll'", "returns":"1"},
1111
{ "expression":"'hello' ~ '^ll'", "returns":"0"},
12-
{ "expression":"'hello' ~ 'llo$'", "returns":"1"}
12+
{ "expression":"'hello' ~ 'llo$'", "returns":"1"},
13+
{ "expression":"'abc123' ~ '\\\\\\\\d+'", "returns":"1"}
1314
]
1415
}

‎resources/function_help/json/regexp_replace

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,8 @@
77
{"arg":"regex","description":"The regular expression to replace. Backslash characters must be double escaped (e.g., \"\\\\\\\\s\" to match a white space character)."},
88
{"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."}
99
],
10-
"examples": [ { "expression":"regexp_replace('QGIS SHOULD ROCK','\\\\\\\\sSHOULD\\\\\\\\s',' DOES ')", "returns":"'QGIS DOES ROCK'"}]
10+
"examples": [ { "expression":"regexp_replace('QGIS SHOULD ROCK','\\\\\\\\sSHOULD\\\\\\\\s',' DOES ')", "returns":"'QGIS DOES ROCK'"},
11+
{ "expression":"regexp_replace('ABC123','\\\\\\\\d+','')", "returns":"'ABC'"},
12+
{ "expression":"regexp_replace('my name is John','(.*) is (.*)','\\\\\\\\2 is \\\\\\\\1')", "returns":"'John is my name'"}
13+
]
1114
}

0 commit comments

Comments
 (0)
Please sign in to comment.