scorpio1441
scorpio1441

Reputation: 3088

preg_match: does not show any value

Not sure why it's not working. Simulated this regexp online at http://regex.larsolavtorvik.com/ and it worked. But not in my PHP.

$val = 'IMG_BE0801s.jpg';
preg_match('/([A-Z]{2}[0-9]{4})/i',$val,$res);
print_r($res);

Please help.

Upvotes: 0

Views: 55

Answers (1)

Dogbert
Dogbert

Reputation: 222198

Works for me.

php> $val = 'IMG_BE0801s.jpg';

php> preg_match('/([A-Z]{2}[0-9]{4})/i',$val,$res);

php> print_r($res);
Array
(
    [0] => BE0801
    [1] => BE0801
)

Upvotes: 1

Related Questions