Home > Software design >  How to match every page that ends on .php EXEPT OF
How to match every page that ends on .php EXEPT OF

Time:11-14

How can I match every page that ends on .php exept of download.php and upload.php?

This matches every page that ends on .php

\.php($|\?)

When I use

^(^(?!download|upload).*)\.php$

download.php is not matched. But however somethingdownload.php is matched.

CodePudding user response:

It looks like you wanted to use what is known as the tempered greedy token solution.

^(?:(?!download|upload).)*\.php$

See this demo at regex101 - Your lookahead is currently triggered just at the ^ start.
To capture the part until .php wrap in a group: ^((?:(?!download|upload).)*)\.php$

  • Related