1.1.0 • Published 6 years ago
gulp-collect-pattern v1.1.0
gulp-collect-pattern
Extract text by regular expression and collect it in a file with gulp.
Usage
Options
Name | Description |
---|---|
file | Collect the extracted text in this file. |
stream | Write the extracted text to this stream. |
regex | Extract text matching this regular expression. |
capture | Collect text from capture group instead of entire match. |
One of file
or stream
must be defined. regex
is required.
Example
We could, for example, extract all inline style tags and collect the contents into an external css file.
var collect = require("gulp-collect-pattern")
var gulp = require("gulp")
gulp.task("html", function () {
return gulp.src("*.html")
.pipe(collect({
file: "./dist/styles.css",
regex: /<style>([\s\S]+?)<\/style>/g,
capture: 1
}))
.pipe(gulp.dest("dist"))
})