my @account = qw(34765-22333-333489-99867-22340-23456-3229 XLM8876 AMP7765 WQP22349); my @chk_acc = split('-',@account); foreach my $checked (@chk_acc) { chomp(); if($checked=~/^(\w{3})(\d{4,7})/ig) { # it should print the accounts starting with letters here print "*$checked*
"; }else{ # else the rest of the accounts not starting with any letters print"-$checked-
"; } }