This won't work, as [] matches only one character from the list inside:
$regexp = '(.+)-(.+)\.[tar.gz|zip]

Intention for this was one was to get file name and version:
preg_match('/^(.+?)-([0-9.]+(?:-.*)|[^-]+)\.(tar.gz$|zip$)/', $file, $matches);

[0-9.] is the same as .. Maybe the dot should be after the "+"?. I don't know what author wanted to express. This whole expression looks a bit broken for me...

CommentFileSizeAuthor
regexp-20050508.diff1.19 KBCvbge

Comments

killes@www.drop.org’s picture

What are you traing to fix?

killes@www.drop.org’s picture

Committed first two chunks.

Steven’s picture

[0-9.] is the same as .

I don't think so... a dot inside [] means the literal dot character, not just any character like outside the square brackets. Try this:

preg_match('/[.]/', 'Drupal'); // prints 0 / false
preg_match('/[.]/', '.'); // prints 1 / true
Anonymous’s picture