我很难使该线程中的答案适应以下问题:
我想拆分以下字符串:
my $string = "foo{age}, bar{height}. something_else. baz{weight,so='yes',brothers=john.smith}.test{some}"
周围的外圆点。结果应该是一个数组持有
("foo{age}, bar{height}",
"foo{weight,parents='yes',brothers=john.smith}",
"test{some}")
我想避免对内部组的内容做出假设{}
。
我怎样才能在 Perl 中做到这一点?
我尝试调整以下内容:
print join(",",split(/,\s*(?=\w+{[a-z,]+})/g, $string));
通过替换字符类中的内容[]
而没有成功。
更新:
组内唯一不允许的字符是或{}
{
}