Feel this is a common use case for but i can’t find too much help online.
Given a test string like "Hello my name is \name{John} \name{Doe}", i would like to remove all curly brackets and the content around them (white space and period is excluding), but keep the content between the brackets. The expected output would be "Hello my name is John Doe".
>Solution :
Try this:
[^ .]*{|}[^ .]*
[^ .]*{
—> [^ .]*
zero or more character except spaces and dots, note there is a space after ^
, followed by a literal {
|
OR
}[^ .]*
—> a literal }
, followed by [^ .]*
zero or more character except spaces and dots.
See regex demo