Range out of order in character class

前端 未结 7 1587
广开言路
广开言路 2020-12-07 00:20

I\'m getting this odd error in the preg_match() function:

Warning: preg_match(): Compilation failed: range out of order in character class at offset 54

The l

7条回答
  •  被撕碎了的回忆
    2020-12-07 01:05

    Hi I got the same error and solved it:

      Warning: preg_match(): Compilation failed: range out of order in character class at offset 
    

    Research Phase:

    .. Range out of order .. So there is a range defined which can't be used.

    .. at offset N .. I had a quick look at my regex pattern. Position N was the "-". It's used to define ranges like "a-z" or "0-9" etc.

    Solution

    I simply escaped the "-".

     \-    
    

    Now it is interpreted as the character "-" and not as range!

提交回复
热议问题