If you want to use a regexp in the condition, the only way to do it is to have the condition be a regexp, that will be applied to the tag itself (ie you can't apply it to the whole path):
#!/usr/bin/perl
use strict;
use warnings;
use XML::Twig;
XML::Twig->new( twig_handlers => { qr/^tag[1-3]/ => sub { print $_->ta
+g, ": ", $_->text, "\n"; } })
->parse( \*DATA);
__DATA__
<result>
<target type="aim">
<tag1>123</tag1>
<tag2>456</tag2>
<nottag>789</nottag>
</target>
</result>
It would be nice to at least be able to apply the regexp to the path, so you could write qr{/result/target/tag[1-3]}. I'll look into it. Further than that, I don't think XML::Twig can do better, at least as it is currently implemented. Allowing the "xpath-like" interpreter to deal with XPath regexp syntax (start-with and the likes) would be a bit difficult, and Perl's regexp syntax and the XPath syntax collide ( [...] is a character class for Perl and a predicate for XPath), so not much hope there.