out of range error in preg match all

Any questions involving matching text strings to patterns - the pattern is called a "regular expression."

Moderator: General Moderators

Post Reply
mayanktalwar1988
Forum Contributor
Posts: 133
Joined: Wed Jul 08, 2009 2:44 am

out of range error in preg match all

Post 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 ?
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: out of range error in preg match all

Post 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:
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Post Reply