# Escaping trouble with the pattern tokenizer/analyzer

**URL:** <https://discuss.elastic.co/t/escaping-trouble-with-the-pattern-tokenizer-analyzer/12170>\
**Category:** Elasticsearch\
**Created:** [May 29, 2013, 12:57pm UTC](https://discuss.elastic.co/t/escaping-trouble-with-the-pattern-tokenizer-analyzer/12170 "2013-05-29T12:57:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kwisarts](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kwisarts/32/2004_2.png) [@kwisarts](https://discuss.elastic.co/u/kwisarts)\
**Post date:** [May 29, 2013, 12:57pm UTC](https://discuss.elastic.co/t/escaping-trouble-with-the-pattern-tokenizer-analyzer/12170/1 "2013-05-29T12:57:15Z")

</div>

Hi,

I tried using the pattern analyzer using the \s pattern for whitespace  
characters.  
There's also an example of this on  
[http://www.elasticsearch.org/guide/reference/index-modules/analysis/pattern-analyzer/](http://www.elasticsearch.org/guide/reference/index-modules/analysis/pattern-analyzer/)

However, using this will fail because JSON will recognize the bashslash as  
an escape sequence:

$ curl -XPUT 'localhost:9200/test' -d '  
{  
"settings":{  
"analysis": {  
"analyzer": {  
"whitespace":{  
"type": "pattern",  
"pattern":"\s+"  
}  
}  
}  
}  
}'  
{"error":"ElasticSearchParseException[failed to parse source for create  
index]; nested: JsonParseException[Unrecognized character escape 's' (code  
115)\n at [Source: [B@3274bcd3; line: 8, column: 38]]; ","status":400}

Can anyone recommend a way to make the JSON Parser accept regular  
expressions?

Thanks,  
David

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![kwisarts](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kwisarts/32/2004_2.png) [@kwisarts](https://discuss.elastic.co/u/kwisarts)\
**Post date:** [May 30, 2013, 11:36pm UTC](https://discuss.elastic.co/t/escaping-trouble-with-the-pattern-tokenizer-analyzer/12170/2 "2013-05-30T23:36:39Z")

</div>

On Wednesday, May 29, 2013 2:57:15 PM UTC+2, David Raison wrote:

> However, using this will fail because JSON will recognize the bashslash as  
> an escape sequence:

Double escaping it actually worked:

"pattern":"\s+"

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 2:33am UTC](https://discuss.elastic.co/t/escaping-trouble-with-the-pattern-tokenizer-analyzer/12170/3 "2017-07-06T02:33:47Z")

</div>


