Live template regex not matching word character

I'm trying to build a regex pattern replacer for a live template variable.

The base variable is $PAYLOAD$

the expression for the result is:

```

regularExpression(PAYLOAD, ":\s*\w+", "")

```

so if I type the payload variable as:

```

foo: string, bar:number

```

I should get the following result:

```

foo, bar

```

As it stands, it's not replacing anything. Testing this with https://www.freeformatter.com/java-regex-tester.html shows the desired result

2 comments
Comment actions Permalink

Try escaping back slashes in your regexp:

regularExpression(PAYLOAD, ":\\s*\\w+", "")

 

0
Comment actions Permalink

Doh, silly mistake. Thanks for clearing that up!

1

Please sign in to leave a comment.