Regular expression for word between {}

I need to capture the ID in between the {} INCLUDING the {} themselves from the below text. The ID changes and all the words around it change but the info I need will always be between the curly brackets.

Navigate to the [systemUnderTest] system and log in with the {testID_jobRole} test ID.

Hi @kasey.betts

Try this:

Without curly braces

(?<=\{).*(?=\})

Input = "Navigate to the [systemUnderTest] system and log in with the {testID_jobRole} test ID."
Output = System.Text.RegularExpressions.Regex.Match(Input,"(?<=\{).*(?=\})").Value.Trim()

With curly Braces

\{.*\}

Regards

@kasey.betts

image

(?<=\{)[\s\S]*?(?=\})

It extracts whatever data in between {} .If it is multilines also it will extract

Hi @kasey.betts

You can use the below regex to extract between Curly braces{}

(?<=\{).*(?=\})

Below regex to extract with {}

\{.*\}

Hope it helps!!

Hi @kasey.betts

Try this:

\{([^}]*)\}

Regards,

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