简体   繁体   中英

Grep file extension using regular expression

I have filenames for examples as below names

1) "Wireshark-win64-1.12.5.exe" 2) "Service - Document.docx"

Is there anyway I can grep the file extension using some generic regular expression and save it in a xslt variable. I was using some string function as below, but for value such as shown above in 1), it won't work.

<xsl:variable name="fileExtension" select="substring-before(substring-after($filename,'.'),'&quot;')"/>

If you're using XSLT 2.0, then:

tokenize($filename, '\.')[last()]

will extract the file extension from $filename for you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM