[英]How to retrieve only filename without greedy extension
I would like to get from 我想从
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
the following: markets-map
, filename.abc
, filename.ab.def
, filename.abc
, abc
, defghi
, location-map
, demographics-map
, demographics-map
with Regex. 以下内容:使用Regex的
markets-map
, filename.abc
, filename.ab.def
, filename.abc
, abc
, defghi
, location-map
, demographics-map
, demographics-map
。 Can you help? 你能帮我吗?
Your problem is specific so you have one way to solve it, it is to solve it case by case here is a regex you can use : 您的问题是特定的,因此您有一种解决方法,这是逐案解决的,您可以使用以下正则表达式:
(.*?)(((\.es\d+)?\.js)|(\.tar\.(bz|zip|ball)))
So you can take only the first group here is regex demo : 因此,您只能参加第一个小组的正则表达式演示:
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.