\ware not supported in regexp query, so you have to use
In Painless Script Language which is the primary script language in Elasticsearch,
Stringdoes not have function
replaceAll, you should use
Matcher.replaceAllinstead, and almost all features are supported. Reference.
Regular expression support is disabled by default in Elasticsearch, you should enable it by editing
elasticsearch.yml. Add a line as below and restart your elasticsearch service:
If your Elasticsearch runs in cluster mode, you need update elasticsearch.yml in each node.