[英]How to retrieve only filename without greedy extension
我想從
markets-map.es6.js
filename.abc.es6.js
filename.ab.def.es6.js
abc.js
defghi.es6.js
location-map.js
demographics-map.es7.js
demographics-map.tar.bz
demographics-map.tar.zip
demographics-map.tar.ball
以下內容:使用Regex的markets-map
, filename.abc
, filename.ab.def
, filename.abc
, abc
, defghi
, location-map
, demographics-map
, demographics-map
。 你能幫我嗎?
您的問題是特定的,因此您有一種解決方法,這是逐案解決的,您可以使用以下正則表達式:
(.*?)(((\.es\d+)?\.js)|(\.tar\.(bz|zip|ball)))
因此,您只能參加第一個小組的正則表達式演示:
Input Output
markets-map.es6.js -> markets-map
filename.abc.es6.js -> filename.abc
filename.ab.def.es6.js -> filename.ab.def
abc.js -> abc
defghi.es6.js -> defghi
location-map.js -> location-map
demographics-map.es7.js -> demographics-map
demographics-map.tar.bz -> demographics-map
demographics-map.tar.zip -> demographics-map
demographics-map.tar.ball -> demographics-map
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.