Regex Pattern Not Capturing Leading Zeros in Version Numbers - Issues in Node.js
This might be a silly question, but I'm trying to use a regular expression in Node.js to capture semantic version numbers (e.g., `1.0.0`, `2.1.3`, `0.5.10`). However, I'm working with issues with matching versions that have leading zeros, like `01.02.03`, which should be valid. My current regex pattern is: ```javascript const versionPattern = /^(\d+\.\d+\.\d+)$/; ``` With this pattern, version numbers with leading zeros are not being matched, and I get an empty array when I test it against `01.02.03`. I've tried modifying the pattern to allow leading zeros, like this: ```javascript const versionPattern = /^(\d{1,2}\d*\.\d{1,2}\d*\.\d{1,2}\d*)$/; ``` However, it still doesn't work as expected, and I end up with the same scenario. The output is just `[]` when I run it against an array of versions that include leading zeros. I also want to ensure that it doesn't accept invalid formats like `1.0.0.1` or `1.0`. Could someone suggest a proper regex pattern that captures all valid version numbers while also supporting leading zeros? I'm using Node.js version 14.17.0. Any help would be greatly appreciated! For context: I'm using Javascript on Linux. What am I doing wrong?