0

I am looking for a regular expression that would allow me to find and replace all instances of strings ending with random numbers, e.g.:

Replace all instances of '/app/build/js/app.min.js?r=123456789

with '/app/build/js/app.min.js?r=' + newValue

I tried the following (in JavaScript), but it doesn't seem to work:

var before = '/app/build/js/app.min.js?r=/[0-9]/g';

I need this for a gulp task, which looks like the following:

  gulp.src(myFile)
    .pipe(replace(before, after))
    .pipe(gulp.dest(myPath));

Any ideas what I'm doing wrong?

1 Answer 1

0

Your regex will only match 1 number. You want to match multiple numbers, so instead of [0-9], use:

\d+$

Which will match one more more numbers coming as the very last thing in the string.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.