I am looking for a pattern in a long string where the long string contains some wildcards. Example:
^ ^ | ^ |\ ^\
Pattern: 123456 123456 123456 123456
The 'x' characters in the long string stands for one or two arbitrary characters in the pattern (ie ..? in regex language. The carets ^ indicate where the pattern would match: in the first place literally, in the second 'x' stands for '4', in the third 'x' is for '45' and in the last 'x' is for '12'.
I could loop over the long string, replace 'x' with '..?' and then match '123456' against the resulting pattern (actually several patterns as the length varies depending on '..?' matching one or two characters) but this would be time consuming for large strings (~millions of characters) and a shame not to fully utilize Perl's matching capabilities.
Is there a way to utilize Perl's regex engine in such a way that the wildcards are in the string rather than the pattern?
Remark: '123456' really are arbitrary characters, no order is implied.