I am having a hard time adapting the answer in this thread to the following problem:
I would like to split the following string:
my $string = "foo{age}, bar{height}. something_else. baz{weight,so='yes',brothers=john.smith}.test{some}"
around the outer dots. The result should be an array holding
("foo{age}, bar{height}",
"foo{weight,parents='yes',brothers=john.smith}",
"test{some}")
I would like to avoid making assumptions about what's inside the groups inside {}
.
How can I do this in Perl?
I tried adapting the following:
print join(",",split(/,\s*(?=\w+{[a-z,]+})/g, $string));
by replacing what's inside the character class []
without success.
Update:
The only characters not allowed within a {}
group are {
or }