Page 1 of 1

out of range error in preg match all

Posted: Wed Jun 09, 2010 10:55 pm
by mayanktalwar1988

Code: Select all

Warning: preg_match_all() [function.preg-match-all]: Compilation failed: range out of order in character class at offset 76 in C:\xampp\htdocs\extracter.php on line 7
what kind of error is this?

the line which this error is pointing is this

Code: Select all

preg_match_all("/(http:\/\/)?(www.)?rapidshare\.com\/[0-9A-Za-z]+\/[0-9A-Za-z]+\/[0-9A-Za-z_-.]+/",$contents1,$out1);
do i have to escape "." in this [0-9A-Za-z_-.]..just like i escaped it to match simply the dot when using outside the range bracket ?

Re: out of range error in preg match all

Posted: Thu Jun 10, 2010 10:23 am
by AbraCadaver
The - character is assumed to designate a range like A-Z, so to use the actual - character it needs to be the first character in your list or escape it.

_-. is not a valid range. :wink: