regex for { } within ' 's
An example,
I have a string that contains let's say:
开发者_运维技巧function main {
// TODO print 'hello {cmd get world} world {nice}!'s asdads
}
How can I select only the words that are in within {}'s and that are inside a ''string. This example would retrieve the output:
{cmd get world; nice}
thanks a lot!
(?<='[^']+\{)[^\{\}]+(?=\}[^']+')
Should do the trick.
Edit: Updated regex to use lookbehind and -aheads.
Edit 2: Regex now matches only the text inside the braces and nothing else.
精彩评论