I have thousands of files in a directory that i am running a batch script on to process.
The relevant files all start with XX-XX-XX (at least one integer, but no more than two, with underscores separating the three numbers)
I used txt2re to create this:
$txt='1-2-3';
$re1='(\\d+)'; # Integer Number 1
$re2='(-)'; # Any Single Character 1
$re3='(\\d+)'; # Integer Number 2
$re4='(-)'; # Any Single Character 2
$re5='(\\d+)'; # Integer Number 3
if ($c=preg_match_all ("/".$re1.$re2.$re3.$re4.$re5."/is", $txt, $matches))
{
$int1=$matches[1][0];
$c1=$matches[2][0];
$int2=$matches[3][0];
$c2=$matches[4][0];
$int3=$matches[5][0];
print "($int1) ($c1) ($int2) ($c2) ($int3)
";
}
Is it possible to get a slightly more compact version of this, that I can compare to the filename in a single function.