How to convert eregi to preg_match?

前端 未结 3 505
花落未央
花落未央 2021-01-05 04:26

I am using a lib which uses

eregi($match=\"^http/[0-9]+\\\\.[0-9]+[ \\t]+([0-9]+)[ \\t]*(.*)\\$\",$line,$matches)

but as eregi is deprecat

3条回答
  •  盖世英雄少女心
    2021-01-05 04:49

    You need to escape the delimiters inside the regular expression (in this case the /):

    "/^http\\/[0-9]+\\.[0-9]+[ \t]+([0-9]+)[ \t]*(.*)\$/i"
    

    But you could also chose a different delimiter like ~:

    "~^http/[0-9]+\\.[0-9]+[ \t]+([0-9]+)[ \t]*(.*)\$~i"
    

提交回复
热议问题