const regex = new RegExp('(?:(?<!\\d|\\-|\\+|\\.)(?P<ch_a>[\\u4e00-\\u9fff]{2})?(?P<Hours>[0-2]?\\d)(?:[:\\.时時]| ?h ?)(?P<Minutes>[0-5]\\d(?!\\d))\\:?(?:(?:[:\\.分]| ?m ?)(?P<Seconds>[0-5]\\d(?!\\d)))?秒?(?:[,\\.](?P<SecodsFraction>\\d{9}|\\d{6}|\\d{3}(?!\\d)))?(?:\\ \\w\\W)?(?:[\\.\\s]?(?:(?P<Z>(?:[a-zA-Z]{3,5}|Z|\\[\\w+\\/\\w+\\])|(?:[+-]\\d\\d?\\:?[0,3,4]?[0,5]?))|(?P<a>[dapmDAPM]{2})))*(?!\\S))', 'gm')
const str = `19990322+0100
19990322
1999-03-22 AD
1999-03-22+01:00
1999-03-22T05:06:07.000[Europe/Paris]
1999-03-22T05:06:07.000
1999-03-22T05:06:07
1999-03-22T05:06:07.000Z
1999-03-22T05:06:07.000+01:00
1999-03-22T05:06:07+01:00
1999-081+01:00
1999W132
1999-W13-2
1999-03-22T05:06:07.000+01:00[Europe/Paris]
1999-03-22T05:06:07+01:00[Europe/Paris]
22.3.99
22.3.99 5.06
22.3.1999 5.06.07
22.3.1999 5:06:07
22-03-99
22-03-99 05:06
22-03-1999 05:06:07
22.03.99
22. März 1999
Montag, 22. März 1999
22.03.1999
22.03.99 05:06
22. März 1999 05:06:07 MEZ
22.03.1999 05:06:07
22.03.99 05:06:07
22.03.1999 05:06
Montag, 22. März 1999 05:06 Uhr MEZ
22-Mar-1999
22/03/99 5:06 AM
Monday, March 22, 1999 5:06:07 o'clock AM CET
22-Mar-1999 5:06:07 AM
22 March 1999
Monday, 22 March 1999
22-Mar-1999
22 March 1999 05:06:07 CET
Monday, 22 March 1999 05:06:07 o'clock CET
22-Mar-1999 05:06:07
22-Mar-99 05.06.07.000000888 AM
3/22/99
03/11/22
03-22-99
3-22-99
Mar 22, 1999
March 22, 1999
Monday, March 22, 1999
Mar 22 1999
March 22 1999
03-22-1999
3-22-1999
1999-03-22+01:00
22/03/1999
22/3/1999
03/22/1999
3/22/1999
1999/3/22
3/22/99 5:06 AM
03/22/99 5:06 AM
03-22-99 5:06 AM
3-22-99 5:06 AM
Mar 22, 1999 5:06:07 AM
Monday, March 22, 1999 5:06:07 AM CET
Mon Mar 22 05:06:07 CET 1999
Mon, 22 Mar 1999 05:06:07 +0100
22 Mar 1999 05:06:07 +0100
03-22-1999 5:06:07 AM
3-22-1999 5:06:07 AM
1999-03-22 5:06:07 AM
1999-3-22 5:06:07 AM
1999-03-22 05:06:07.0
22/03/1999 5:06:07 AM
22/3/1999 5:06:07 AM
03/22/1999 5:06:07 AM
3/22/1999 5:06:07 AM
03/22/99 5:06:07 AM
03/22/99 5:06:07
3/22/99 5:06:07
22/03/1999 5:06 AM
22/3/1999 5:06 AM
03/22/1999 5:06 AM
3/22/1999 5:06 AM
03-22-99 5:06:07 AM
3-22-99 5:06:07 AM
03-22-1999 5:06 AM
3-22-1999 5:06 AM
1999-03-22 5:06 AM
1999-3-22 5:06 AM
Mar.22.1999
22/Mar/1999 5:06:07 +0100
22/Mar/99 5:06 AM
22/03/99
22/03/99 5:06
22.3.99 5:06
22.03.99
22.03.1999
22.03.99 5:06
22.03.1999 5:06:07
22.3.1999
22.3.1999 5:06
99-03-22
1999-03-22
22 mars 1999 05:06:07 CET
March 22, 1999 5:06:07 CET AM
1999-03-22 05:06:07
lundi 22 mars 1999 5 h 06 CET
22/03/99
22 mars 1999
22 mars 1999
lundi 22 mars 1999
22/03/99 05:06
03/22/99 05:06
3/22/99 05:06
03-22-99 05:06
3-22-99 05:06
22 mars 1999 05:06:07
22 mars 1999 05:06:07 CET
03-22-1999 05:06:07
3-22-1999 05:06:07
1999-3-22 05:06:07
22/03/1999 05:06:07
22/3/1999 05:06:07
03/22/1999 05:06:07
3/22/1999 05:06:07
lundi 22 mars 1999 05 h 06 CET
22/03/99 05:06:07
03/22/99 05:06:07
3/22/99 05:06:07
22/03/1999 05:06
22/3/1999 05:06
03/22/1999 05:06
3/22/1999 05:06
03-22-99 05:06:07
3-22-99 05:06:07
03-22-1999 05:06
3-22-1999 05:06
1999-3-22 05:06
99/03/22 05:06
1999.03.22
1999.03.22 05:06:07
1999.03.22 05:06
1999.03.22.
1999.03.22. 5:06:07
1999.03.22. 5:06
22.3.1999 05:06:07
22.3.1999 05:06
22-mar-1999
22/03/99 5.06
99-03-22 05:06
22-mar-1999 5.06.07
22 marzo 1999 5.06.07 CET
lunedì 22 marzo 1999 5.06.07 CET
05:06 22/03/99
05:06:07 22/03/1999
99/03/22
1999/03/22
99/03/22 5:06
03/22/99 5:06
3/22/99 5:06
03-22-99 5:06
3-22-99 5:06 AM
03-22-1999 5:06:07
3-22-1999 5:06:07
1999-03-22 5:06:07
99/03/22 5:06:07
3/22/99 5:06:07 AM
1999/03/22 5:06
22/03/1999 5:06
22/3/1999 5:06
03/22/1999 5:06
3/22/1999 5:06
03-22-99 5:06:07
3-22-99 5:06:07
03-22-1999 5:06
3-22-1999 5:06
1999-03-22 5:06
1999-3-22 5:06
99. 3. 22
1999. 3. 22
99.3.22
99.3.22 05.06
1999-03-22 05.06.07
99.22.3
1999.22.3
99.22.3 05:06
1999.22.3 05:06:07
22.3.99 05:06
22.3.1999 05:06:
22-3-99
22-3-99 5:06
22-03-1999
22-03-1999 5:06
22.03.99 5:06
22.03.1999 5:06:07
1999-03-22 5:06:07.PD
99-03-22 5.06.PD
1999-03-22 5.06.07.PD CET
22.3.99.
22.03.1999.
22.3.99. 05.06
22.03.1999. 05.06.07
22.03.1999. 05.06.07 CET
05:06:07 22-03-1999
05:06 22/03/1999
99-3-22
1999-3-22
1999年3月22日
1999年3月22日 星期一
99-3-22 上午5:06
1999-3-22 5:06:07
1999年3月22日 上午05时06分07秒
1999年3月22日 5時06分07秒 CET
1999年3月22日 星期一 上午05时06分07秒 CET
`;
// 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