More Regular Expression Questions

Hi guys,

As always I am here looking for advice regarding Regular Expressions.

I have a file with several HEX colour values (i.e. #FF1122). The best I can come up with is the following (but it doesn’t work):

$color_file = 'text #FFFFFF text';

$found = preg_match_all('/^#([a-fA-F0-9])$/i', $color_file, $matches);

echo $matches . "\
" . $found . "\

I just get an empty array. :frowning:

Please help…

The ^ in a regular expression matches the start of the string, and the $-sign the end of the string.

$found = preg_match_all('/\\#([a-f0-9]{3,6})/i', $color_file, $matches);