#!perl -wl use strict; $_ = "[ABC AB AB12/83]"; print "I have a string like this\n$_"; s{\[([A-Z_]+)\s([A-Z_]+)\s([A-Z_]+)(\d+)/(\d+)\]}{$1_$2_$3$4_$5}; print "I would like to end up with\n$_";