I need to validate a string like "[one.two.three]", where titles are separated by ".", there has to be a minimum of at least one title. Each title needs to be extracted. Is there any way to do this in a loop or does it have to be two separate steps?
use strict;
use warnings;
my @tests = ("[one]", "[two.three.four]");
foreach (@tests) {
while ($_ =~ /^\[(\w+)(?:\.\w+)*\]$/) {
print "$1\n";
}
print "\n\n\n";
}