如何将表达式与不同的模式匹配

时间:2016-04-19 11:58:14

标签: regex splunk

我需要匹配以下模式来提取文件类型。

    <fo:page-sequence-master master-name="Imprints">
        <fo:repeatable-page-master-alternatives>
            <fo:conditional-page-master-reference master-reference="PageMaster.Blank" blank-or-not-blank="blank"/>
            <fo:conditional-page-master-reference master-reference="PageMaster.Title-Page"/>
        </fo:repeatable-page-master-alternatives>
    </fo:page-sequence-master>
    <fo:page-sequence-master master-name="TOC">
        <fo:repeatable-page-master-alternatives>
            <fo:conditional-page-master-reference master-reference="PageMaster.Blank" blank-or-not-blank="blank"/>
            <fo:conditional-page-master-reference master-reference="PageMaster.TOC"/>
        </fo:repeatable-page-master-alternatives>
    </fo:page-sequence-master>
    <fo:page-sequence-master master-name="CopyRight-Page">
        <fo:repeatable-page-master-alternatives>
            <fo:conditional-page-master-reference master-reference="PageMaster.Blank" blank-or-not-blank="blank"/>
            <fo:conditional-page-master-reference master-reference="PageMaster.CopyRight-Page"/>
        </fo:repeatable-page-master-alternatives>
    </fo:page-sequence-master>
    <fo:page-sequence-master master-name="Content-Pages">
        <fo:repeatable-page-master-alternatives>
            <fo:conditional-page-master-reference master-reference="PageMaster.Blank" blank-or-not-blank="blank"/>
            <fo:conditional-page-master-reference master-reference="PageMaster.Page-Right.First" page-position="first"/>
            <fo:conditional-page-master-reference master-reference="PageMaster.Page-Left" odd-or-even="even"/>
            <fo:conditional-page-master-reference master-reference="PageMaster.Page-Right" odd-or-even="odd"/>
        </fo:repeatable-page-master-alternatives>
...
<fo:page-sequence master-reference="Imprints">
...
<fo:page-sequence master-reference="CopyRight-Page" initial-page-number="auto-odd">
...
<fo:page-sequence master-reference="PageMaster.TOC" initial-page-master="auto-odd">
...
<xsl:for-each select="//tei:div[@n='1']">
    <fo:page-sequence master-reference="Content-Pages" initial-page-number="auto-odd">

试图提取文件类型

some text here ../../file/path/dir/200.FILETYPE.234234.20150404_092222.xml and some text
some random text here ../../file/path/dir/FILETYPE.345223.SOMETEXT.20150404_092222.xml and some other text

但它在提取的字段中选择FILETYPE.345223而不仅仅是FILETYPE。它正确提取FILETYPE,因为在xml之前只有3个点。任何帮助表示赞赏。

注意:FILETYPE可以是jpg,png等任何单词。

示例路径: ../../file/path/dir/jpg.345223.SOMETEXT.20150404_092222.xml ../../file/path/dir/200.jpg.3235223.SOMETEXT.20150404_092222.something.xml ../../file/path/dir/png.SOMETEXT.SOMETEXT.20150404_092222.xml

在png或jpg之后

之前可以有3或4个点

1 个答案:

答案 0 :(得分:0)

^.* (.*\/dir\/[^\.]*)\.([^ ]*).*$

组1是路径+文件名,组2是文件类型(第一个点到下一个空白后的所有内容)