提取特殊字符之间的字符串

Extract strings between special characters

请帮我从这个文本中提取字符串,例如

  1. id1:value1,id2:value2

  2. id1:value1a,id2:value2a

来自

"[{id1:value1,id2:value2},{id1:value1a,id2:value2a}]"

{([^}]+)} 将找到并捕获 { }

中的任何内容

你应该在你的问题中包含更多细节,并表明你自己已经尝试过。

工作代码

unlist(regmatches(text, gregexpr("\\{.*?\\}", text)))

unlist(regmatches(text, gregexpr("\\{([^}]+)\\}", text)))