# Backreference in regex

**URL:** https://discuss.elastic.co/t/backreference-in-regex/312299
**Category:** Beats
**Tags:** filebeat, auditbeat
**Created:** [August 17, 2022, 2:48pm UTC](https://discuss.elastic.co/t/backreference-in-regex/312299 "2022-08-17T14:48:58Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Lukas\_Hubl](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lukas_hubl/32/100118_2.png) [@Lukas\_Hubl](https://discuss.elastic.co/u/Lukas_Hubl)
#### Post date: [August 17, 2022, 2:48pm UTC](https://discuss.elastic.co/t/backreference-in-regex/312299/1 "2022-08-17T14:48:58Z")

</div>

Hi,  
is it possible to use backreference for regex in auditbeat/filebeat?  
I am trying something like this:  
`\"1\":\"(\w+)\",\"2\":\"\1\"`  
and the following string should match:  
`"1":"string","2":"string"`

But I am getting error:  
`Exiting: error initializing processors: failed to initialize condition: error parsing regexp: invalid escape sequence: \1`

---

<div class="post-metadata">

### Author: ![andrewkroh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andrewkroh/32/3784_2.png) [@andrewkroh](https://discuss.elastic.co/u/andrewkroh)
#### Post date: [August 18, 2022, 3:11am UTC](https://discuss.elastic.co/t/backreference-in-regex/312299/2 "2022-08-18T03:11:45Z")

</div>

[re2](https://github.com/google/re2/wiki/Syntax) does not support backreferences.

---

<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: [September 15, 2022, 5:11am UTC](https://discuss.elastic.co/t/backreference-in-regex/312299/3 "2022-09-15T05:11:50Z")

</div>

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