I would like to split the string: "Hello[You]All"
to the following array:
H,e,l,l,o,[You],A,l,l
I tried to do it with split:
my $str = "Hello[You]All";
my @list = split(/(\[.*?\]|.)/, $str);
foreach (@list) {
print "->$_\n";
}
Since I tried something that split is not supposed to do, it gave me the following array:
,H,,e,,l,,l,,o,,[You],,A,,l,,l,
Next step I need to take is to remove the empty spaces.
While it is not the best solution it is the only one I found, without anything too messy. I'm posting here to ask if anyone knows a better way to solve this task?