I have a PHP regEx, how do add a condition for the number of characters?

前端 未结 5 1795
臣服心动
臣服心动 2021-01-27 02:00

I have a regular expression that Im using in php:

$word_array = preg_split(
    \'/(\\/|\\.|-|_|=|\\?|\\&|html|shtml|www|php|cgi|htm|aspx|asp|index|com|net|o         


        
5条回答
  •  半阙折子戏
    2021-01-27 02:22

    I'm guessing you're building a URL router of some kind.

    Detecting which parameters are useful and which are not should not be part of this code. It may vary per page whether a short parameter is relevant.

    In this case, couldn't you just ignore the 1'th element? Your page should (or 'handler') should have knowledge over which parameters it wants to be called with, it should do the triage.

提交回复
热议问题