Php regular matches doc or pdf extension

php regular match doc or pdf extension
match doc or pdf extension
1212.doc
1419421.pdf

in the following document
  preg_match_all("|(.*).doc|U", $namelist[$j], $nn[$j]);

previously used is | (. *). Doc | U, which can only match doc,. Now I want both pdf and doc to match. How can I rewrite

?
Jun.16,2021

"/ (. *)\. B (doc | pdf)\ b /"

or

"(. +?)\. (pdf | doc)"


^. *?. (pdf | doc) $


< H2 > use the pathinfo method in conjunction with in_array < / H2 >
  
(. *). (doc | pdf)
Menu