tianxiacangshen
V2EX  ›  PHP

正则路由缺陷

  •  
  •   tianxiacangshen · Dec 13, 2017 · 2271 views
    This topic created in 3086 days ago, the information mentioned may be changed or developed.
    "/^domain\/(.*)$/"=>'Index/domain?domain=:1',

    翻阅资料得知(.*)匹配除换行符之外的所有内容,但是这里,总是匹配不到 url 里面最后一个 . 后面的内容:

    __ROOT__/domain/baidu 得到 baidu
    __ROOT__/domain/baidu.com 得到还是 baidu
    __ROOT__/domain/www.baidu.com 得到还是 www.baidu
    __ROOT__/domain/www.baidu.aaa 得到还是 www.baidu

    最后一个 . 后面的字符完全没办法获取到,为啥?
    2 replies    2017-12-14 00:25:46 +08:00
    weixiangzhe
        1
    weixiangzhe  
       Dec 14, 2017
    ![]( )
    ![]( )
    . 的意思是 all,没毛病

    https://regexper.com/#%2F%5Edomain%5C%2F(.*)%24%2F
    weixiangzhe
        2
    weixiangzhe  
       Dec 14, 2017 via iPhone
    貌似看错,卤煮忽略我,不过感觉不是正则的锅
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3471 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 10:41 · PVG 18:41 · LAX 03:41 · JFK 06:41
    ♥ Do have faith in what you're doing.