my $input = 'ABC 1 ABC-1 DEF2 DEF-2 3XYZ 3-XYZ';print "Input:\n\"$input\"\n\nOutput(s):\n";print "\"$_\"\n" for ($input =~ m/([^\sa-z\-]+|[^\s0-9\-]+)/ig);
Standard input is empty
Input: "ABC 1 ABC-1 DEF2 DEF-2 3XYZ 3-XYZ" Output(s): "ABC" "1" "ABC" "1" "DEF" "2" "DEF" "2" "3" "XYZ" "3" "XYZ"
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!