Repository: webpack-contrib/copy-webpack-plugin (js)

Issue:
toType detection has broken "to: '[1]'"
* Operating System: MacOS
* Node Version: 10.15.3
* NPM Version: 6.9.0
* webpack Version: 4.29.6
* copy-webpack-plugin Version: 5.0.2

### Expected Behavior

You should be able to specify a to: like '[1]' or 'foo/[1]'.

### Actual Behavior

Files are being put in a literal directory named '[1]'.

### Code

I believe this is caused somewhere in this change: https://github.com/webpack-contrib/copy-webpack-plugin/commit/52f8be6809ae0b876225973d34ff65a3b6009192

I apologize for not submitting a PR instead, as that is my preferred way to deal with bugs, but I do not have time to dig on this right now.

### How Do We Reproduce?

Create a to: setting of '[1]' that is a replacement from a RegExp test.

Pull request description:
fix: alone `[N]` interpolation in `to` option
<!--
  HOLY CRAP a Pull Request. We ❤️ those!

  If you remove or skip this template, you'll make the 🐼 sad and the mighty god
  of Github will appear and pile-drive the close button from a great height
  while making animal noises.

  Please place an x (no spaces!) in all [ ] that apply
-->

This PR contains a:

- [x] **bugfix**
- [ ] new **feature**
- [ ] **code refactor**
- [x] **test update** <!-- if bug or feature is checked, this should be too -->
- [ ] **typo fix**
- [ ] **metadata update**

### Motivation / Use-Case

fix bug

### Breaking Changes

No

### Additional Info

fixes #369 fixes #373

Patch:
diff --git a/src/utils/isTemplateLike.js b/src/utils/isTemplateLike.js
index ead6d5c..a06b396 100644
--- a/src/utils/isTemplateLike.js
+++ b/src/utils/isTemplateLike.js
@@ -1,4 +1,4 @@
 export default (pattern) =>
-  /(\[ext\])|(\[name\])|(\[path\])|(\[folder\])|(\[emoji(?::(\d+))?\])|(\[(?:([^:\]]+):)?(?:hash|contenthash)(?::([a-z]+\d*))?(?::(\d+))?\])/.test(
+  /(\[ext\])|(\[name\])|(\[path\])|(\[folder\])|(\[emoji(?::(\d+))?\])|(\[(?:([^:\]]+):)?(?:hash|contenthash)(?::([a-z]+\d*))?(?::(\d+))?\])|(\[\d+\])/.test(
     pattern
   );


Test patch:
diff --git a/test/CopyPlugin.test.js b/test/CopyPlugin.test.js
index 24ab24f..4e834a6 100644
--- a/test/CopyPlugin.test.js
+++ b/test/CopyPlugin.test.js
@@ -1808,6 +1808,21 @@ describe('apply function', () => {
         .catch(done);
     });
 
+    it('can move multiple files to a non-root directory with [1]', (done) => {
+      runEmit({
+        expectedAssetKeys: ['nested/txt'],
+        patterns: [
+          {
+            from: 'directory/nested/deep-nested',
+            to: 'nested/[1]',
+            test: /\.(.*)$/,
+          },
+        ],
+      })
+        .then(done)
+        .catch(done);
+    });
+
     it("can move a directory's contents to the root directory from symbolic link", (done) => {
       runEmit({
         // Windows doesn't support symbolic link