miyuki

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

  •  
  •   miyuki · Dec 6, 2014 via Android · 2756 views
    This topic created in 4356 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
    imn1
    Dec 6, 2014❤️1
    1
    \[(.+)\.[^\.]+
    由于给出的例子不具代表性,这个正则不通用
    lincanbin
    lincanbin
    Dec 6, 2014❤️1
    2
    str_replace(strrchr($FileName, '.'),"",$FileName)
    正则效率低,不过这种会去除所有.doc
    MaiCong
    MaiCong
    Dec 6, 2014 via iPhone
    3
    按照.doc
    MaiCong
    MaiCong
    Dec 6, 2014 via iPhone❤️1
    4
    以.doc为关键词转换为数组,然后提取出来就行了...
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1025 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 37ms · UTC 22:38 · PVG 06:38 · LAX 14:38 · JFK 17:38
    ♥ Do have faith in what you're doing.