Created
November 9, 2018 13:42
-
-
Save ivanrosolen/2bd74b8db873ed57a979920e656cd8a7 to your computer and use it in GitHub Desktop.
Named Capturing Group REGEX
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$regex = "/(?'group1'[0-9]+)_(?'group2'.+)_(?'group3'[0-9A-Z]+).(?'ext'.+)$/"; | |
$files = [ | |
'01_lero_1X.pdf', | |
'02_lerolero_13.pdf', | |
'03_1k_KK.pdf' | |
]; | |
foreach ($files as $key => $name) { | |
preg_match($regex, $name, $matches); | |
print_r($matches); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment