开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜