# Replace regex for capture group

**URL:** https://community.fibery.io/t/replace-regex-for-capture-group/5735
**Category:** Get Help
**Created:** [January 23, 2024, 10:03am UTC](https://community.fibery.io/t/replace-regex-for-capture-group/5735 "2024-01-23T10:03:29Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![YvetteLans](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/yvettelans/32/6101_2.png) [@YvetteLans](https://community.fibery.io/u/YvetteLans)
#### Post date: [January 23, 2024, 10:03am UTC](https://community.fibery.io/t/replace-regex-for-capture-group/5735/1 "2024-01-23T10:03:30Z")

</div>

I have a text field which currently has values that are comma separated.

I need the strings separated by square brackets instead.

The AI function in Fibery’s formula and ChatGPT both offers the same solution.

ReplaceRegex(Name, “^(.\*)$”, “[$1]”)

But it seems that Fibery can’t handle the capture group since the outcome is [$1].

Does anyone know how to solve this?

Thanks!

---

<div class="post-metadata">

### Author: ![Chr1sG](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/chr1sg/32/3941_2.png) [@Chr1sG](https://community.fibery.io/u/Chr1sG)
#### Post date: [January 23, 2024, 10:30am UTC](https://community.fibery.io/t/replace-regex-for-capture-group/5735/2 "2024-01-23T10:30:13Z")

</div>

Try this:

```auto
ReplaceRegex(
  ReplaceRegex(
    ReplaceRegex(Text, "(?<=\w)$", "]"),
  "^(?=\w)", "["),
", *", "][")

```

It adds `]` at the end, adds `[` at the beginning and then replaces every instance of `, ` or `,` with `][`

Note: It assumes that there are no line breaks in the source string

---

<div class="post-metadata">

### Author: ![YvetteLans](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/yvettelans/32/6101_2.png) [@YvetteLans](https://community.fibery.io/u/YvetteLans)
#### Post date: [January 23, 2024, 1:15pm UTC](https://community.fibery.io/t/replace-regex-for-capture-group/5735/3 "2024-01-23T13:15:39Z")

</div>

Awesome 🤩 Works like a charm. Nothing beats ChrisGPT 😏
