|
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Hi all
If I am using a regex like this: <?php if(preg_match('/(jpe?g?|png|gif)$/i',$extension)){ do something... } ?> It works. But if I do: <?php $images = 'jpe?g?|png|gif'; if(preg_match('/('.$images.')$/i',$extension)){ do something... } ?> (I simply replaced the content of the regex between parenthesis with the variable $images.) It does not work, it seems that whatever the extension is, it always matches. That's probably very stupid, but it's bugging me What am I missing? -- seb (@webtrans1.com) high-end web design: http://webtrans1.com Sign-up for a free beta test of SiteLander, an ingenious website-builder: http://webtrans1.com/sitelander/ music: http://myspace.com/popmodelberlin |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
OK so I also tried this:
$images = '/(jpe?g?|png|gif)$/i'; if(preg_match($images, $extension)){ do_something } it does not work either. Now there is never a match. I guess it must be a problem with the modifiers at the end of the variable used as a pattern? How should I do this???? -- seb (@webtrans1.com) high-end web design: http://webtrans1.com Sign-up for a free beta test of SiteLander, an ingenious website-builder: http://webtrans1.com/sitelander/ music: http://myspace.com/popmodelberlin |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
(_seb_) wrote:
> OK so I also tried this: > > $images = '/(jpe?g?|png|gif)$/i'; > > if(preg_match($images, $extension)){ > do_something > } > > it does not work either. Now there is never a match. > > I guess it must be a problem with the modifiers at the end of the > variable used as a pattern? > > How should I do this???? > OOps! it was another stupid error that had nothing to do with the regex... sorry. -- seb (@webtrans1.com) high-end web design: http://webtrans1.com Sign-up for a free beta test of SiteLander, an ingenious website-builder: http://webtrans1.com/sitelander/ music: http://myspace.com/popmodelberlin |
|
![]() |
| Outils de la discussion | |
|
|