Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix "Unterminated regular expression literal" error in JavaScript?

I did check these multiple questions on SO, but so far none has the answer. Very simple regex that giving error "Unterminated regular expression literal" near the escaped dot. Regex should match ./images/.

const regex = new RegExp(/\.\/images\/);
const options = {
    files: [
        './style/_styles.scss'
      ],
    from: [regex],
    to: ['./../dist/primeng-lib/images/']
  };
like image 926
andrey.shedko Avatar asked Dec 31 '25 03:12

andrey.shedko


1 Answers

In your first line, you forgot the closing regex delimiter.

Change this:

const regex = new RegExp(/\.\/images\/);

To this

const regex = new RegExp(/\.\/images\//);
like image 59
ewen-lbh Avatar answered Jan 02 '26 16:01

ewen-lbh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!