gulp-collect-pattern

1.1.0 • Public • Published

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"))
})

/gulp-collect-pattern/

    Package Sidebar

    Install

    npm i gulp-collect-pattern

    Weekly Downloads

    77

    Version

    1.1.0

    License

    GPL-3.0

    Unpacked Size

    38.4 kB

    Total Files

    5

    Last publish

    Collaborators

    • redhatter