Search code examples
.netregexnintex-workflow

Regex Action in Nintex workflow only replace first instance


I have a Nintex Workflow for a SharePoint 2013 list, and am trying to use the Regular Expressions Action to edit a string. I believe Nintex uses the Microsoft .NET standard for Regex. I am trying to remove the FIRST occurrence of a parenthesis in a string. Here is my input text:

Douglas Christopher W) I have some (comments) to add.

Using Regex, I can use the Pattern

\)

And the Replacement Text

:

But that will change ALL the occurrences of the ) character, returning

Douglas Christopher W: I have some (comments: to add.

How do I turn off the global flag and just convert the first instance?


Solution

  • Alternatively, you could use a capturing group matching not a closing parenthesis [^)]* using a negated character class followed by matching the closing parenthesis.

    I the replacement refer to the capturing group followed by a :

    ^([^)]*)\)
    

    Regex demo

    Replace with:

    $1: