Bakri
Bakri

Reputation: 707

Regex to find string between to special character

I have string like this

abc{[data1]}efg{[data2]}

I need a regex that returns data1 and data2.

I tried Regex(@"{[\w*]}") but no hope.

Upvotes: 0

Views: 61

Answers (1)

Wiktor Stribiżew
Wiktor Stribiżew

Reputation: 627536

You need to escape the special regex characters, otherwise [\w*] is treated as 1 word character or an asterisk:

@"\{\[\w*\]}"
  ^ ^    ^

See demo

Upvotes: 1

Related Questions