Regular Expressions 101

Community Patterns

Name and ID in curly braces

0

Regular Expression
.NET 7.0 (C#)

@"
(?<=^\{)(.*?)(\d*?)(?=\}$)
"
gm

Description

For a string that starts with '{' and ends with '}' looks for a name and id value within the curly braces. The name group should be trimmed when used to remove leading and trailing whitespace.

Ex. {Test10} will result in 2 groups being returned Group 1: Test Group 2: 10

Submitted by Ryan Felton - 2 years ago