const regex = /(\d{3})(\d{3})(\d{4})/g;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('(\\d{3})(\\d{3})(\\d{4})', 'g')
const str = `7809392938
4033420393
7808757619
7804627372
4033431930
7804401427
3065843029
3068734346
3065459158
4032513899
6138371733
6136396120
6133220669
6132832702
7056961818
8195233827
8195379506
8193710857
6044659476
5065360323
9025972293
9026675158
3064418455
7808952118
6134731171
4188779045
4186634875
4162860104
9056469563
6136344085
9054536644
5192827449
7053682779
7057521683
7054767377
7054971162
7057593131
8075472443
9054782200
4168386400
7053270706
7056896545
5197823445
5194557669
5195425944
5194262785
9057762200
8193369296
4509373605
5143860399
4503489425
4506781069
4182962342
8679207104
9059739040
7058474747
2505806048
2502180257
6042709933
4164348199
7057210639
7057349081
2504791217
3063733403
5065460100
7803973778
6049434754
9023544384
5068709204
4037196000
2508820609
2509611173
7095898574
3066915254
4183975361
9028375909
5199157304
4189483659
8196842529
5064507449
5063575494
5063672576
6048929667
3068915205
5066331384
2503655167
2502653235
2507529278
2506245540
2505674718
7097494516
7095767638
7098320809
9026792314
9026442913
9026442293
9028658567
9027369404
9027423186
9028933908
4035278016
4032265840
4033278207
3062492680
2042756980
2046385237
2043393316
4506470945
4187383045
2505372791
9026872112
5193744315
4165968575
4036523816
6137283666
2504447144
4187360000
4188150011
8676672570
4504784078
5194810153
7806251607
4186957692
4506494109
6132668702
2507663003
6049901059
6139302145
2507232093
5199423280
6134765593
5064595336
5193519378
2508301088
8196372035
9028753656
9059346500
8075770789
6477909063
6049465187
7056462443
2505922183
7782161820
5192653223
5063974955
7092564814
4033370181
8198773421
9023683266
4033908888
3066936127
5199416173
4167812753
8676687380
6048460630
6137964840
5193376209
2506355865
2508474469
7056626061
9053080060
9054597533
9057237320
7803324545
2505542598
9026388451
8193783753
2507632056
5067354659
2505542955
7059465040
2046873964
6042028854
2048425342
7097456052
7056925631
9025661497
4509331802
4035274710
5195833619
5144575112
6136344247
5192419733
9055716776
6134760233
2504266049
6477634195
5146070708
5067552960
3069809211
4503022369
7804543304
7804637212
4032088354
4032819500
8673349753
8679207515
2507835562
4037586887
2508252215
7092273714
4186724195
6134157330
9052784681
4508354914
6047323899
8076226386
7807157130
5068588300
6133899546
4035273688
6042234345
2504931671
8198408405
2506890329
2507218688
6045911825
6044698609
3069241004
9055502464
4507772134
4166881095
5194733618
7057495520
9053324976
6042715299
6048856208
2503378239
2502454938
2506275956
5066331384
7053601885
6043392005
6472959264
4508186798
5146953528
2508324265
8079372062
8198555822
6136322153
2894311030
6049850214
9024364910
9028364364
2504422663
7059421737
9052799187
9057360310
4037586427
4183000661
9028257522
5144819024
4509644266
4039020100
3066347693
7053350460
5068321992
7057439571
7804674856
6138974467
5146298848
8677664124
5067399737
9028636932
7787824971
6042506974
5199698893
2508608660
5197370274
6042001562
6472004306
4167595783
3067782686
7804678679
6472338817
7057457119
7808122731
2507543528
4504717099
6135307723
4507993777
8195646350
7804794690
5197437840
4505300810
5196335949
4502248479
9023964040
4168547404
4033806498
2044779125
9025821561
9024662124
9024044215
7054812054
7097486282
6042437418
5064723929
5064548676
5064585957
5146884163
7059875411
7808269012
3066523701
7097271098
6134537921
2507684212
8192229743
4189624834
2509270781
4185628441
5194897027
7806675393
`;
// 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