const regex = /(^\-?0[\,\.][0-9]{1,}$)|(^\-?[1-9][0-9]{1,}$)|(^[0-9]$)|(^\-?[1-9][0-9]{0,}[\,\.][0-9]{1,}$)|(^\-?[1-9]$)/gm;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('(^\\-?0[\\,\\.][0-9]{1,}$)|(^\\-?[1-9][0-9]{1,}$)|(^[0-9]$)|(^\\-?[1-9][0-9]{0,}[\\,\\.][0-9]{1,}$)|(^\\-?[1-9]$)', 'gm')
const str = `01
001
033
0000033
00000.2
00000000000000
01010101010
0000.0
aaa
???!!!!!
111%\$\$\$\$
-0
-
-100
-100.255
-10.25555
-1.2
-1335354.12
-22
-2
-1
-13353544366564547
-0.22222298
-0.2
-0,2989080
-6767676767676767677676767677676
-0.22
-123
-1
100.255
10.25555
1.2
1335354.12
22
2
1
13353544366564547
0.22222298
0.2
0,2989080
6767676767676767677676767677676
0
0.22
123`;
// Reset `lastIndex` if this regex is defined globally
// regex.lastIndex = 0;
let m;
while ((m = regex.exec(str)) !== null) {
// This is necessary to avoid infinite loops with zero-width matches
if (m.index === regex.lastIndex) {
regex.lastIndex++;
}
// The result can be accessed through the `m`-variable.
m.forEach((match, groupIndex) => {
console.log(`Found match, group ${groupIndex}: ${match}`);
});
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for JavaScript, please visit: https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions