如何在gulp.src中使用基本正则表达式? [英] How to use basic regular expressions within gulp.src?

查看:110
本文介绍了如何在gulp.src中使用基本正则表达式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用gulp.src选择两个文件:highcharts.jshighcharts.src.js.

I'm trying to select two files with gulp.src: highcharts.js and highcharts.src.js.

我当然知道我可以使用数组表达式显式地添加这两个表达式,但是出于学习目的,我试图为它们编写一个表达式.

Of course I know I could add explicitly these two with an array expression, but for learning purposes I'm trying to write a single expression for them.

我已经读过一个人可以使用简单的正则表达式语法,但不清楚如何使用.

I've read that one can use simple regular expression syntax but it's not clear how.

我尝试了

gulp.src("highcharts(\.src)?\.js")

但没有任何文件.

推荐答案

Gulp使用 glob 不支持您通常使用的正则表达式.它使用经过特殊优化的匹配模式来匹配文件.

Gulp uses glob which doesn't support the regular expressions you're normally used to. It uses special globbing patterns that are optimized to matching files.

您的示例可以写为:

gulp.src('highcharts?(.src).js')

查看 glob入门,以获得有关.

Check out the glob primer for more examples of what's possible with glob.

这篇关于如何在gulp.src中使用基本正则表达式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆