M
M
Margo19642016-09-27 21:07:37
Node.js
Margo1964, 2016-09-27 21:07:37

How to leave only numbers in Gulp Rename?


rename = require("gulp-rename");
.pipe(rename({

Takes the original name of the file. It is necessary that the name be displayed in dest, in which only numbers remain from the original. How to do it?
file-546219-orig.jpg => 546219.jpg

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Belyaev, 2016-09-27
@Margo1964

.pipe(rename(function (path) {
    path.basename = path.basename.replace(/\D/g, '');
}))

I wrote from the phone, or rather copied from the docks of the module to npm and the rules (which the modern generation, obviously, cannot do), so I can’t vouch for the correctness

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question