miyuki

如何匹配文件名(除了.扩展名的部分)

  •  
  •   miyuki · Dec 6, 2014 via Android · 2388 views
    This topic created in 4178 days ago, the information mentioned may be changed or developed.
    PHP

    扩展名为 .doc 或 .docx
    文件名部分为任意字符


    example
    [2013级期末考试试题.doc] 只匹配 [2013级期末考试试题] 部分
    4 replies    2014-12-06 21:04:08 +08:00
    imn1
        1
    imn1  
       Dec 6, 2014   ❤️ 1
    \[(.+)\.[^\.]+
    由于给出的例子不具代表性,这个正则不通用
    lincanbin
        2
    lincanbin  
       Dec 6, 2014   ❤️ 1
    str_replace(strrchr($FileName, '.'),"",$FileName)
    正则效率低,不过这种会去除所有.doc
    MaiCong
        3
    MaiCong  
       Dec 6, 2014 via iPhone
    按照.doc
    MaiCong
        4
    MaiCong  
       Dec 6, 2014 via iPhone   ❤️ 1
    以.doc为关键词转换为数组,然后提取出来就行了...
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3068 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 33ms · UTC 09:10 · PVG 17:10 · LAX 02:10 · JFK 05:10
    ♥ Do have faith in what you're doing.