'Regular expression for sequences of word characters enclosed in braces

I have an input string containing some words (as in \w+) all enclosed by curly braces. I need to capture the individual words with a regular expression.

For example, from this input:

{abc 123... 456!}

I need to capture the following strings:

"abc", "123", "456"

So far, I have been able to capture words using the pattern /(\w+)\W*/ when the words are not enclosed by curly braces. But all my attempts to develop the pattern further to support the outer curly braces have failed.



Solution 1:[1]

What programming language are you using?
We could apply regex twice:

\{[^{}]+\}

will return the contents of the curly braces
and then

[^{] ]+

will return the individual values

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1