Just add parentheses in the search for anexo
:
/[a-z]{3}_(ANEXO|Anexo|anexo)_[A-Za-z]{1,7}_[A-Z]{1}_[A-Z0-9]{2,5}....pdf/
Try RegEx101 .
More complete solution, providing brackets:
The user @DiegoFelipe has posted to the comments an improved solution, which switches the "wildcards" "( ...
) by the brackets ( \[[0-9]{1}\]
) (note the difference at the end):
/[a-z]{3}_(ANEXO|Anexo|anexo)_[A-Za-z]{1,7}_[A-Z]{1}_[A-Z0-9]{2,5}\[[0-9]{1}\].pdf$/
See the test on IDEONE .
Issue @Guilherme Lautert
If the word "attachment" is not case-sensitive, lowercase:
[a-z]{3}_((?i)anexo)_[A-Za-z]{1,7}_[A-Z]{1}_[A-Z0-9]{2,5}...\.pdf
Test RegEx101.
A slightly shorter alternative if it is rigorous:
[a-z]{3}_(ANEXO|(A|a)nexo)_[A-Za-z]{1,7}_[A-Z]{1}_[A-Z0-9]{2,5}...\.pdf
Test RegEx101.