# Painless regex

**URL:** <https://discuss.elastic.co/t/painless-regex/209089>\
**Category:** Kibana\
**Created:** [November 22, 2019, 4:27pm UTC](https://discuss.elastic.co/t/painless-regex/209089 "2019-11-22T16:27:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Incauto](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/incauto/32/60149_2.png) [@Incauto](https://discuss.elastic.co/u/Incauto)\
**Post date:** [November 22, 2019, 4:27pm UTC](https://discuss.elastic.co/t/painless-regex/209089/1 "2019-11-22T16:27:24Z")

</div>

Hi, Im trying to extract the "ABCD\_123.123.123.123" part from an adress, can you help me figure it out?

ABCD\_123.123.123.123\_DD\_FS

This is what I have tried, but it trows me an error at the beggining of the regex

```
def m = /^_DD_FS$/.matcher(doc['server'].value);
 if ( m.matches() ) {
    return m.group(1)
}
```

---

<div class="post-metadata">

**Author:** ![Brandon\_Kobel](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/brandon_kobel/32/14829_2.png) [@Brandon\_Kobel](https://discuss.elastic.co/u/Brandon_Kobel)\
**Post date:** [November 22, 2019, 6:34pm UTC](https://discuss.elastic.co/t/painless-regex/209089/2 "2019-11-22T18:34:45Z")

</div>

Hey @Incauto, are you seeing the following error?

```auto
 "Regexes are disabled. Set [script.painless.regex.enabled] to [true] in elasticsearch.yaml to allow them. Be careful though, regexes break out of Painless's protection against deep recursion and long loops.

```

---

<div class="post-metadata">

**Author:** ![Incauto](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/incauto/32/60149_2.png) [@Incauto](https://discuss.elastic.co/u/Incauto)\
**Post date:** [November 23, 2019, 9:57pm UTC](https://discuss.elastic.co/t/painless-regex/209089/3 "2019-11-23T21:57:10Z")

</div>

Thanks, I just have to add the line _script_ . _painless_ . _regex_ . _enabled_ to my elasticsearch.yml

---

<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:** [December 21, 2019, 9:57pm UTC](https://discuss.elastic.co/t/painless-regex/209089/4 "2019-12-21T21:57:23Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
