I'm trying for couple of days to create a regex for finding the correct picture by the product barcode from the pictures folder. The folder containing something like 4500 pictures. The name of the file can be in 4 formats.
- XXXXXX.jpg/png - short barcode unknown number of characters(numbers only).
- 00000(from 1 to unknow number of leading zero)XXXX(then the short barcode).jpg/png
- 729(as leading number)00000(from 1 to unknow number of leading zero)XXXX(then the short barcode).jpg/png
- 72900000XXXXXXYYY YYY YYY.jpg/png same as option 3 but with some characters(Y-represent a character).
I came up with something like that:
$i = new RegexIterator($a, '($barcode)\D*|^([0][0-9]+$barcode)\D+|(729[0-9][0-9]+$barcode)\D+|(729[0-9][0-9]+$barcode).+/', RegexIterator::GET_MATCH);
$barcode - can be 7290000232 or 0000232 or 232
But it doesn't working. Any ideas?