-
Notifications
You must be signed in to change notification settings - Fork 25.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* [DOCS] Adds note about escaping backslashes in regex * Fix typo * Simplify example
- Loading branch information
1 parent
74f25d0
commit 8e9ffd2
Showing
1 changed file
with
32 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,7 +37,38 @@ backslash or surround it with double quotes. For example: | |
\\ # renders as a literal '\' | ||
"[email protected]" # renders as '[email protected]' | ||
.... | ||
|
||
|
||
[NOTE] | ||
==== | ||
The backslash is an escape character in both JSON strings and regular | ||
expressions. You need to escape both backslashes in a query, unless you use a | ||
language client, which takes care of this. For example, the string `a\b` needs | ||
to be indexed as `"a\\b"`: | ||
[source,console] | ||
-------------------------------------------------- | ||
PUT my-index-000001/_doc/1 | ||
{ | ||
"my_field": "a\\b" | ||
} | ||
-------------------------------------------------- | ||
This document matches the following `regexp` query: | ||
[source,console] | ||
-------------------------------------------------- | ||
GET my-index-000001/_search | ||
{ | ||
"query": { | ||
"regexp": { | ||
"my_field.keyword": "a\\\\.*" | ||
} | ||
} | ||
} | ||
-------------------------------------------------- | ||
//TEST[continued] | ||
==== | ||
|
||
[discrete] | ||
[[regexp-standard-operators]] | ||
|