-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathregex_about_month.txt
1466 lines (1276 loc) · 568 KB
/
regex_about_month.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
User:Ohconfucius/AWB modules/mdy
From Wikipedia, the free encyclopedia
< User:Ohconfucius
Jump to navigationJump to search
//all dates to mdy
//
WikiFunctions.Parse.HideText ht = new WikiFunctions.Parse.HideText(true, false, true);
public string ProcessArticle(string ArticleText, string ArticleTitle, int wikiNamespace, out string Summary, out bool Skip)
{
Skip = false;
Summary = "";
ArticleText = ht.Hide(ArticleText);
////User:Ohconfucius/AWB modules/dmy
//protect dates
ArticleText=Regex.Replace(ArticleText, @"(?i)(\[\[September)( 11 attacks\|)", "$1♫$2");
ArticleText=Regex.Replace(ArticleText, @"(?i)(100\s)(crore club\D)", "$1♫$2");
// ArticleText=Regex.Replace(ArticleText, @"(?i)(september\s)(11\D)", "$1♫$2");
//fix common errors
//rem superscripted ordinals
ArticleText=Regex.Replace(ArticleText, @"(?i)(\d)<sup>(th|st|nd|rd)<\/sup>", "$1$2");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[([12]?\d|30|31)(?:th|st|nd|rd|)(?:_| )(Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|June?|July?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)", "[[$1 $2");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|June?|July?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)(?:_| )([12]?\d|30|31)(?:th|st|nd|rd|)", "[[$1 $2");
//month+day piped to month+day
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(?:[12]?\d|30|31)(?:th|st|nd|rd|)\s(?:Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|June?|July?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)\|(\d{1,2}\s)(?:th|st|nd|rd|)(Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|June?|July?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)\]\]", "[[$1$2]]");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(?:Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|June?|July?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)\s(?:[12]?\d|30|31)(?:th|st|nd|rd|)\|(\d{1,2}\s)(?:th|st|nd|rd|)(Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|June?|July?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)\]\]", "[[$1$2]]");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[\d{1,2}\s(?:Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|June?|July?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)\|(Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|June?|July?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)(\s\d{1,2})(?:th|st|nd|rd|)\]\]", "[[$1$2]]");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(?:Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|June?|July?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)\s(?:[12]?\d|30|31)(?:th|st|nd|rd|)\|(Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|June?|July?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)(\s\d{1,2})(?:th|st|nd|rd|)\]\]", "[[$1$2]]");
//month+day piped to number
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(?:[12]?\d|30|31)(?:th|st|nd|rd|)\s(?:Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|June?|July?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)\|(\d{1,4})\]\]", "[[$1]]");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(?:Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|June?|July?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)\s(?:[12]?\d|30|31)(?:th|st|nd|rd|)\|(\d{1,4})\]\]", "[[$1]]");
//part dates
//remove leading zeros from dts templates
ArticleText=Regex.Replace(ArticleText, @"(?i)({{dts\d?\|[^}]*\|)0([^}]*}})", "$1$2");
//delink ISO dates
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[([12]\d{3}-\d\d-\d\d)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[([12]\d{3})\]\]-\[\[(\d\d-\d\d)\]\]", "$1-$2");
ArticleText=Regex.Replace(ArticleText, @"(?i)([12]\d{3})-\[\[(\d\d-\d\d)\]\]", "$1-$2");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[([12]\d{3})\]\]-(\d\d-\d\d)", "$1-$2");
//remove year in xxxx
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(?:1[7-9]|20)\d{2}\sin\s[^\|\]]+\|(\d{4})\]\]", "$1");
//remove dts1 template that links ISO dates
ArticleText=Regex.Replace(ArticleText, @"(?i)\{\{dts1\|(\d{4}-\d\d-\d\d)\}\}", "$1");
// century
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[((?:first|second|third|fourth|fifth|sixth|seventh|eighth|ninth|tenth|eleventh|twelfth|thirteenth|fourteenth|fifteenth|sixteenth|seventeenth|eighteenth|nineteenth|twentieth|twenty(?:\s|-)first)(?:\s|-))century\]\]", "$1century");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[((?:first|second|third|fourth|fifth|sixth|seventh|eighth|ninth|tenth|eleventh|twelfth|thirteenth|fourteenth|fifteenth|sixteenth|seventeenth|eighteenth|nineteenth|twentieth|twenty(?:\s|-)first)(?:\s|-))century\s(AD|BC|CE|BCE)\]\]", "$1century");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(\d{1,2}(?:st|nd|rd|th)(?:\s|-))century\]\]", "$1century");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(\d{1,2}(?:st|nd|rd|th)(?:\s|-))centuries\]\]", "$1centuries");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[\d{1,2}(?:st|nd|rd|th)(?:\s|-)century\|(\d{1,2}(?:st|nd|rd|th))\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[\d{1,2}(?:st|nd|rd|th)(?:\s|-)century\|(\d{1,2}(?:st|nd|rd|th)(?:\s|-))century\]\]", "$1century");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[\d{1,2}(?:st|nd|rd|th)(?:\s|-)century\|(\d{1,2}(?:st|nd|rd|th)(?:\s|-))centuries\]\]", "$1centuries");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(\d{1,2}(?:st|nd|rd|th)(?:\s|-))century\s(AD|BC|CE|BCE)\]\]", "$1century $2");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[\d{1,2}(?:st|nd|rd|th)(?:\s|-)century\|(\d{1,2}(?:st|nd|rd|th)(?:\s|-))century\s(AD|BC|CE|BCE)\]\]", "$1century $2");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[\d{1,2}(?:st|nd|rd|th)(?:\s|-)century\|(\d{1,2}(?:st|nd|rd|th)(?:\s|-))centuries\s(AD|BC|CE|BCE)\]\]", "$1centuries $2");
// decades and years
ArticleText=Regex.Replace(ArticleText, @"\[\[(\d{1,3}0)\'?s\]\]", "$1s");
ArticleText=Regex.Replace(ArticleText, @"\[\[\d{1,3}0\'?s\|([^\]]{1,30})\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(\d{1,3}0)\'?(s)?[\s_]?(AD|BC|CE|BCE)\]\]", "$1$2 $3");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[\d{1,3}0\'?s?[\s_]?(?:AD|BC|CE|BCE)\|([^\]]{1,30})\]\]", "$1");
//year: now remove unprotected linked years
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[((?:1[0-9]|20)\d{2}|[1-9]\d{0,2})([\s_]?(?:AD|BC|CE|BCE)|)\]\]", "$1$2");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[\d{1,3}0\'?s?[\s_]?\(decade\)\|([^\]]{1,30})\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(\d{1,3}0)\'?s", "$1s");
// solitary day_numbers
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December)\s\d{1,2}(?:th|st|nd|rd)\|(\d{1,2})(?:th|st|nd|rd)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[\d{1,2}(?:th|st|nd|rd)\s(?:January|February|March|April|May|June|July|August|September|October|November|December)\|(\d{1,2})(?:th|st|nd|rd)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(\d{1,2}(?:st|nd|rd|th))\]\]", "$1");
//month+year
//Identify surprise or 'Easter egg' diversions linking month+years to year articles. Turn them into month+year links to be dealt with below
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[\d{1,4}#[^\|\]]+\|((?:January|February|March|April|May|June|July|August|September|October|November|December)\s\d{3,4})\]\]", "[[$1]]");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[((?:January|February|March|April|May|June|July|August|September|October|November|December)\s\d{3,4})\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(?:Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.?|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))\s\d{3,4}\|([^\]]{1,30})\]\]", "$1");
//removed piped years when in full date
ArticleText=Regex.Replace(ArticleText, @"(?i)(\[\[\d{1,2}\s(?:January|February|March|April|May|June|July|August|September|October|November|December)\]\],?\s?\[\[)[^\|\]]{1,32}\|(\d{1,4}\]\])", "$1$2");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December)\s\d{1,2}\]\],?\s?\[\[)[^\|\]]{1,32}\|(\d{1,4}\]\])", "$1$2");
//remove piped years
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(?:19\d|20[01])\d in (?:aviation|baseball|film|literature|comics|ireland|india)\|((?:19|20)\d{2})\]\]", "$1");
//Identify surprise or 'Easter egg' diversions linking months to year articles.
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[\d{1,4}#[^\|\]]+\|(January|February|March|April|May|June|July|August|September|October|November|December)\]\]", "$1");
//Month+day_number "March 7th" -> "March 7"
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))\s(\d?\d)(?:th|st|nd|rd)\]\]", "[[$1 $2]]");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[((?:Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))\s\d?\d)\]\](?:th|st|nd|rd)", "[[$1]]");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(\d?\d)(?:th|st|nd|rd)\s(January|February|March|April|May|June|July|August|September|October|November|December)\]\]", "$1 $2");
//Remove nbsp within date strings
ArticleText=Regex.Replace(ArticleText, @"(?i)(\D\d{1,3})(th|st|nd|rd) (?=\w)", "$1$2 ");
ArticleText=Regex.Replace(ArticleText, @"(?i)(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|)) (\d?\d(?:th|st|nd|rd|)\D)", "$1 $2");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\D\d?\d)(?:th|st|nd|rd|) (Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))(?=\W)", "$1 $2");
ArticleText=Regex.Replace(ArticleText, @"(?i)(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))\s* \s*((?:19\d|20[01])\d)(?=\D)", "$1 $2");
//(month yyyy-month yy)
ArticleText=Regex.Replace(ArticleText, @"(?i)\((Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.?|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))\s(20)([01]\d)\s?[-–]\s?(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.?|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))\s([01]\d)\)", "($1 $2$3–$4 $2$5)");
ArticleText=Regex.Replace(ArticleText, @"(?i)\((Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.?|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))\s(19)([3-9]\d)\s?[-–]\s?(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.?|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))\s([3-9]\d)\)", "($1 $2$3–$4 $2$5)");
ArticleText=Regex.Replace(ArticleText, @"(?i)\((Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.?|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))\s(19)(9\d)\s?[-–]\s?(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.?|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))\s([01]\d)\)", "($1 $2$3–$4 20$5)");
ArticleText=Regex.Replace(ArticleText, @"(?:the\s?|)([1-2]?\d|30|31)(?:th|st|nd|rd|), ([1-2]?\d|30|31)(?:th|st|nd|rd|)(\s(?:and|&|to|or)\s[1-3]?\d)(?:th|st|nd|rd|)(?:\sof\s?)?\s(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))(?=\W)", "$1, $2$3 $4");
ArticleText=Regex.Replace(ArticleText, @"(?:the\s?|)([1-2]?\d|30|31)(?:th|st|nd|rd|)(\s(?:and|&|to|or)\s|[-–])([1-3]?\d)(?:th|st|nd|rd|)(?:\sof\s?)?\s(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))(?=\W)", "$1$2$3 $4");
ArticleText=Regex.Replace(ArticleText, @"(?:the\s?|)([1-2]?\d|30|31)(?:th|st|nd|rd|)(?:\sof\s?)\s(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))(?=[^\|\]\w\d])", "$1 $2");
ArticleText=Regex.Replace(ArticleText, @"(?:the\s?|)([1-2]?\d|30|31)(?:th|st|nd|rd|)(?:\sof\s?)?\s(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))(?=\W)", "$1 $2");
ArticleText=Regex.Replace(ArticleText, @"(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))\s(?:the\s|)([1-2]?\d|30|31)(?:th|st|nd|rd|),\s(?:the\s|)([1-2]?\d|30|31)(?:th|st|nd|rd|)(\s(?:and|&|to|or)\s)(?:the\s|)([1-2]?\d|30|31)(?:th|st|nd|rd|)(?=[^\]\|\w\d]\D)", "$1 $2, $3$4 $5");
ArticleText=Regex.Replace(ArticleText, @"(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))\s(?:the\s|)([1-2]?\d|30|31)(?:th|st|nd|rd|)(\s(?:and|&|to|or)\s)(?:the\s|)([1-2]?\d|30|31)(?:th|st|nd|rd|)(?=[^\]\|\w\d]\D)", "$1 $2$3$4");
ArticleText=Regex.Replace(ArticleText, @"(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))\s(?:the\s|)([1-3]?\d)(?:th|st|nd|rd)(?=[^\]\|\w\d]\D)", "$1 $2");
ArticleText=Regex.Replace(ArticleText, @"(\s*=\s*)((?:19|20)\d\d)\s+(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))\s([1-3]?\d)(?=[\s\r\n]*[\|\}])", "$1$4 $3 $2");
ArticleText=Regex.Replace(ArticleText, @"(\s*\()((?:19|20)\d\d)\s+(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))\s([1-3]?\d)(?=\))", "$1$4 $3 $2");
//Month+day_number piped into number. Preferences do not work. They don't work in sequence because digits in the two dates must be adjacent
ArticleText=Regex.Replace(ArticleText, @"(?i)([^\[]{4})\[\[((?:January|February|March|April|May|June|July|August|September|October|November|December)\s\d?\d)\]\](\s?\-?\s?)\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December)\s\d{1,2}(?:th|st|nd|rd)\|(\d{1,2}(?:th|st|nd|rd))\]\]", "$1$2$3$4");
//same again but with ndash or mdash instead of hyphen
ArticleText=Regex.Replace(ArticleText, @"(?i)([^\[]{4})\[\[((?:January|February|March|April|May|June|July|August|September|October|November|December)\s\d?\d)\]\](\s?&[nm]dash;\s?)\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December)\s\d{1,2}(?:th|st|nd|rd)\|(\d{1,2}(?:th|st|nd|rd))\]\]", "$1$2$3$4");
//same again but with slash instead of hyphen
ArticleText=Regex.Replace(ArticleText, @"(?i)([^\[]{4})\[\[((?:January|February|March|April|May|June|July|August|September|October|November|December)\s\d?\d)\]\](\/)\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December)\s\d{1,2}(?:th|st|nd|rd)\|(\d{1,2}(?:th|st|nd|rd))\]\]", "$1$2$3$4");
ArticleText=Regex.Replace(ArticleText, @"(?i)([^\[]{4})\[\[((?:January|February|March|April|May|June|July|August|September|October|November|December)\s\d?\d)\]\](\s?\-?\s?)\[\[(\d{1,2}(?:th|st|nd|rd))\]\]", "$1$2$3$4");
//same again but with ndash instead of hyphen
ArticleText=Regex.Replace(ArticleText, @"(?i)([^\[]{4})\[\[((?:January|February|March|April|May|June|July|August|September|October|November|December)\s\d?\d)\]\](\s?&[nm]dash;\s?)\[\[(\d{1,2})\]\]", "$1$2$3$4");
//same again but with slash instead of hyphen
ArticleText=Regex.Replace(ArticleText, @"(?i)([^\[]{4})\[\[((?:January|February|March|April|May|June|July|August|September|October|November|December)\s\d?\d)\]\](\/)\[\[(\d{1,2}(?:th|st|nd|rd))\]\]", "$1$2$3$4");
ArticleText=Regex.Replace(ArticleText, @"(?i)([^\[]{4})\[\[(\d?\d)\s(?:January|February|March|April|May|June|July|August|September|October|November|December)\]\](\s?\-?\s?)\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December)\s\d{1,2}(?:th|st|nd|rd)\|(\d{1,2}(?:th|st|nd|rd))\]\]", "$1$2$3$4");
//same again but with ndash instead of hyphen
ArticleText=Regex.Replace(ArticleText, @"(?i)([^\[]{4})\[\[(\d?\d)\s(?:January|February|March|April|May|June|July|August|September|October|November|December)\]\](\s?&[nm]dash;\s?)\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December)\s\d{1,2}(?:th|st|nd|rd)\|(\d{1,2}(?:th|st|nd|rd))\]\]", "$1$2$3$4");
//same again but with slash instead of hyphen
ArticleText=Regex.Replace(ArticleText, @"(?i)([^\[]{4})\[\[(\d?\d)\s(?:January|February|March|April|May|June|July|August|September|October|November|December)\]\](\/)\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December)\s\d{1,2}(?:th|st|nd|rd)\|(\d{1,2}(?:th|st|nd|rd))\]\]", "$1$2$3$4");
ArticleText=Regex.Replace(ArticleText, @"(?i)([^\[]{4})\[\[(\d?\d)\s(?:January|February|March|April|May|June|July|August|September|October|November|December)\]\](\s?\-?\s?)\[\[(\d{1,2}(?:th|st|nd|rd))\]\]", "$1$2$3$4");
//same again but with ndash instead of hyphen
ArticleText=Regex.Replace(ArticleText, @"(?i)([^\[]{4})\[\[(\d?\d)\s(?:January|February|March|April|May|June|July|August|September|October|November|December)\]\](\s?&[nm]dash;\s?)\[\[(\d{1,2}(?:th|st|nd|rd))\]\]", "$1$2$3$4");
//same again but with slash instead of hyphen
ArticleText=Regex.Replace(ArticleText, @"(?i)([^\[]{4})\[\[(\d?\d)\s(?:January|February|March|April|May|June|July|August|September|October|November|December)\]\](\/)\[\[(\d{1,2}(?:th|st|nd|rd))\]\]", "$1$2$3$4");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December)\s\d{1,2}(?:th|st|nd|rd)\|(\d{1,2}(?:th|st|nd|rd))\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[\d{1,2}(?:th|st|nd|rd)\s(?:January|February|March|April|May|June|July|August|September|October|November|December)\|(\d{1,2}(?:th|st|nd|rd))\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December)\s\d{1,2}(?:th|st|nd|rd)\|((?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d{1,2}(?:th|st|nd|rd))\]\]", "$1");
//month+day piped into month+day or vice versa
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[\d{1,2}(?:th|st|nd|rd)\s(?:January|February|March|April|May|June|July|August|September|October|November|December)\|((?:January|February|March|April|May|June|July|August|September|October|November|December)\s\d{1,2}(?:th|st|nd|rd))\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December)\s\d{1,2}(?:th|st|nd|rd)\|(\d{1,2}(?:th|st|nd|rd)\s(?:January|February|March|April|May|June|July|August|September|October|November|December))\]\]", "$1");
//4 digit years piped into 2
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[\d{1,4}\|(\d{1,2}(?:th|st|nd|rd))\]\]", "$1");
//full dates with incorrect 'year in'
ArticleText=Regex.Replace(ArticleText, @"(?i)(\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December)\s(?:[0-3][\d]|[\d])\]\]),\s\[\[(\d{1,4})\sin\s[^\]]{1,32}\]\]", "$1 $2");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\[\[(?:[0-3][\d]|[\d])\s(?:January|February|March|April|May|June|July|August|September|October|November|December)\]\])\s\[\[(\d{1,4})\sin\s[^\]]{1,32}\]\]", "$1 $2");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\[\[(?:[0-3][\d]|[\d])\s(?:January|February|March|April|May|June|July|August|September|October|November|December)\]\])\s{{(?:avyear|by|fy|ly|scy|sdy)\|(\d{1,4})}}", "$1 [[$2]]");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December)\s(?:[0-3][\d]|[\d])\]\]),\s\{\{(?:avyear|by|fy|ly|scy|sdy)\|(\d{1,4})\}\}", "$1 [[$2]]");
//insert comma to separate date from army unit
ArticleText=Regex.Replace(ArticleText, @"(?i)(January|February|March|April|May|June|July|August|September|October|November|December) (the \d\d*@th (?:Air(?:borne|)|Arm(?:ou?red|y)|Artillery|Battalion|Brigade|Co(?:mpan|)y|Division|Fleet|Group|Infantry|Land|Panzer|Regiment|Squadron|Sqn)\b)", "$1, $2");
// remove nowrap template from dm and md dates
ArticleText=Regex.Replace(ArticleText, @"(?i)(date=)\{\{nowrap\|(?:([0-2]?\d|30|31)(?:[ _]| )(January|February|March|April|May|June|July|August|September|October|November|December))\}\}", "$1$2 $3");
ArticleText=Regex.Replace(ArticleText, @"(?i)(date=)\{\{nowrap\|(?:(January|February|March|April|May|June|July|August|September|October|November|December)(?:[ _]| )([0-2]?\d|30|31))\}\}", "$1$2 $3");
//remove leading zero from linked date
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|June?|July?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)\s0(\d)(?:th|st|nd|rd|)\]\]", "[[$1 $2]]");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[0(\d)(?:th|st|nd|rd|)\s(Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|June?|July?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)\]\]", "[[$1 $2]]");
//delink dates to mdy; strip ordinals
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|June?|July?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)\s(\d?\d)(?:th|st|nd|rd|)(?:\]\],?\s?\[\[|,?\s)(\d{1,4})\]\]", "$1 $2, $3");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|June?|July?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)\s(\d?\d)(?:th|st|nd|rd|)\]\],?\s?(\d{1,4})(\W)", "$1 $2, $3$4");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|June?|July?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)\s(\d?\d)(?:th|st|nd|rd|)\]\]", "$1 $2");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(\d?\d)(?:th|st|nd|rd|)\s(Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|June?|July?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)(?:\]\],?\s?\[\[|,?\s)(\d{1,4})\]\]", "$2 $1, $3");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(\d?\d)(?:th|st|nd|rd|)\s(Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|June?|July?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)\]\],?\s?(\d{1,4})(\W)", "$2 $1, $3$4");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(\d?\d)(?:th|st|nd|rd|)\s(Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|June?|July?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)\]\]", "$2 $1");
//change deprecated birth and death templates
ArticleText=Regex.Replace(ArticleText, @"(?i)\|df=ye?s?", "");
// ArticleText=Regex.Replace(ArticleText, @"(?i)(\{\{(?:Birth|Death|launch|release|start|end|film date|Wayback)[^\}\|]*\|)", "$1df=yes|");
// ArticleText=Regex.Replace(ArticleText, @"(?i)(\{\{(?:Birth|Death|launch|release|start|end|film date|Wayback)[^\}\|]*\|)df=ye?s?\|([^}]*df=ye?s?)", "$1$2");
// eliminating time of day
ArticleText=Regex.Replace(ArticleText, @"(?i)(\|[ ]*author[ ]*=[ ]*)(?:posted|published)(?: by| on|)[\s:](?=\w)", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\|[ ]*(?:date|archivedate|accessdate|author)[ ]*=[ ]*)[0-2]?\d:[0-5]\d(?:[ ]| )(?:[ap]m |[ap]\.m\. |)([A-Z]{1,2}T|UTC)[\.,]?[ ]?", "$1");
// eliminating days of the week
ArticleText=Regex.Replace(ArticleText, @"(?i)(\|[ ]*(?:date|archivedate|accessdate|author)[ ]*=[ ]*)(?:(?:Mon|Tues|Wednes|Thurs|Fri|Satur|Sun)day,?)\s", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\|[ ]*(?:date|archivedate|accessdate|author)[ ]*=[ ]*)(?:(?:Mon|Tues?|Wed|Thur?|Fri|Sat|Sun)[\.,]?)\s", "$1");
// eliminating dates placed in author parameter
ArticleText=Regex.Replace(ArticleText, @"(?i)(\|\s*author\s*=\s*)@month @day,? @yyyy\s?(?:,? \d?\d:\d\d(?:\s*| )(?:[apAP][mM]\s*|)(?:GMT\s*|UTC\s*|[A-Z]{1,2}[DS]T\s*|)|)\|", "|");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\|\s*author\s*=\s*)@day @month,? @yyyy\s?(?:,? \d?\d:\d\d(?:\s*| )(?:[apAP][mM]\s*|)(?:GMT\s*|UTC\s*|[A-Z]{1,2}[DS]T\s*|)|)\|", "|");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\|[ ]*(?:date|archivedate|accessdate)[ ]*=[ ]*)Jan\.? ([1-9]|[1-2][0-9]|30|31), ([1-2][0-9]{3})(?=\s*[\|\}])", "$1January $2, $3");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\|[ ]*(?:date|archivedate|accessdate)[ ]*=[ ]*)Feb\.? ([1-9]|[1-2][0-9]|30|31), ([1-2][0-9]{3})(?=\s*[\|\}])", "$1February $2, $3");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\|[ ]*(?:date|archivedate|accessdate)[ ]*=[ ]*)Mar\.? ([1-9]|[1-2][0-9]|30|31), ([1-2][0-9]{3})(?=\s*[\|\}])", "$1March $2, $3");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\|[ ]*(?:date|archivedate|accessdate)[ ]*=[ ]*)Apr\.? ([1-9]|[1-2][0-9]|30|31), ([1-2][0-9]{3})(?=\s*[\|\}])", "$1April $2, $3");
// ArticleText=Regex.Replace(ArticleText, @"(?i)(\|[ ]*(?:date|archivedate|accessdate)[ ]*=[ ]*)@Month ([1-9]|[1-2][0-9]|30|31), ([1-2][0-9]{3})(?=\s*[\|\}])", "$1Fullmonth $2, $3");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\|[ ]*(?:date|archivedate|accessdate)[ ]*=[ ]*)@Jun\.? ([1-9]|[1-2][0-9]|30|31), ([1-2][0-9]{3})(?=\s*[\|\}])", "$1June $2, $3");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\|[ ]*(?:date|archivedate|accessdate)[ ]*=[ ]*)(?:Jly|Jul\.?) ([1-9]|[1-2][0-9]|30|31), ([1-2][0-9]{3})(?=\s*[\|\}])", "$1July $2, $3");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\|[ ]*(?:date|archivedate|accessdate)[ ]*=[ ]*)Aug\.? ([1-9]|[1-2][0-9]|30|31), ([1-2][0-9]{3})(?=\s*[\|\}])", "$1August $2, $3");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\|[ ]*(?:date|archivedate|accessdate)[ ]*=[ ]*)Sep. ([1-9]|[1-2][0-9]|30|31), ([1-2][0-9]{3})(?=\s*[\|\}])", "$1September $2, $3");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\|[ ]*(?:date|archivedate|accessdate)[ ]*=[ ]*)Oct\.? ([1-9]|[1-2][0-9]|30|31), ([1-2][0-9]{3})(?=\s*[\|\}])", "$1October $2, $3");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\|[ ]*(?:date|archivedate|accessdate)[ ]*=[ ]*)Nov\.? ([1-9]|[1-2][0-9]|30|31), ([1-2][0-9]{3})(?=\s*[\|\}])", "$1November $2, $3");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\|[ ]*(?:date|archivedate|accessdate)[ ]*=[ ]*)Dec\.? ([1-9]|[1-2][0-9]|30|31), ([1-2][0-9]{3})(?=\s*[\|\}])", "$1December $2, $3");
ArticleText=Regex.Replace(ArticleText, @"(?i)(<ref[^>]*>(?:[^<]+?[\s\(]|))Jan\.? ([1-9]|[1-2][0-9]|30|31), ([1-2][0-9]{3})(?=(?:[^\w\/\-%,<][^<]*?|)<\/ref>)", "$1January $2, $3");
ArticleText=Regex.Replace(ArticleText, @"(?i)(<ref[^>]*>(?:[^<]+?[\s\(]|))Feb\.? ([1-9]|[1-2][0-9]|30|31), ([1-2][0-9]{3})(?=(?:[^\w\/\-%,<][^<]*?|)<\/ref>)", "$1February $2, $3");
ArticleText=Regex.Replace(ArticleText, @"(?i)(<ref[^>]*>(?:[^<]+?[\s\(]|))Mar\.? ([1-9]|[1-2][0-9]|30|31), ([1-2][0-9]{3})(?=(?:[^\w\/\-%,<][^<]*?|)<\/ref>)", "$1March $2, $3");
ArticleText=Regex.Replace(ArticleText, @"(?i)(<ref[^>]*>(?:[^<]+?[\s\(]|))Apr\.? ([1-9]|[1-2][0-9]|30|31), ([1-2][0-9]{3})(?=(?:[^\w\/\-%,<][^<]*?|)<\/ref>)", "$1April $2, $3");
// ArticleText=Regex.Replace(ArticleText, @"(?i)(<ref[^>]*>(?:[^<]+?[\s\(]|))May ([1-9]|[1-2][0-9]|30|31), ([1-2][0-9]{3})(?=(?:[^\w\/\-%,<][^<]*?|)<\/ref>)", "$1Fullmonth $2, $3");
ArticleText=Regex.Replace(ArticleText, @"(?i)(<ref[^>]*>(?:[^<]+?[\s\(]|))Jun\.? ([1-9]|[1-2][0-9]|30|31), ([1-2][0-9]{3})(?=(?:[^\w\/\-%,<][^<]*?|)<\/ref>)", "$1June $2, $3");
ArticleText=Regex.Replace(ArticleText, @"(?i)(<ref[^>]*>(?:[^<]+?[\s\(]|))(?:Jly|Jul\.?) ([1-9]|[1-2][0-9]|30|31), ([1-2][0-9]{3})(?=(?:[^\w\/\-%,<][^<]*?|)<\/ref>)", "$1July $2, $3");
ArticleText=Regex.Replace(ArticleText, @"(?i)(<ref[^>]*>(?:[^<]+?[\s\(]|))Aug\.? ([1-9]|[1-2][0-9]|30|31), ([1-2][0-9]{3})(?=(?:[^\w\/\-%,<][^<]*?|)<\/ref>)", "$1August $2, $3");
ArticleText=Regex.Replace(ArticleText, @"(?i)(<ref[^>]*>(?:[^<]+?[\s\(]|))Sep. ([1-9]|[1-2][0-9]|30|31), ([1-2][0-9]{3})(?=(?:[^\w\/\-%,<][^<]*?|)<\/ref>)", "$1September $2, $3");
ArticleText=Regex.Replace(ArticleText, @"(?i)(<ref[^>]*>(?:[^<]+?[\s\(]|))Oct\.? ([1-9]|[1-2][0-9]|30|31), ([1-2][0-9]{3})(?=(?:[^\w\/\-%,<][^<]*?|)<\/ref>)", "$1October $2, $3");
ArticleText=Regex.Replace(ArticleText, @"(?i)(<ref[^>]*>(?:[^<]+?[\s\(]|))Nov\.? ([1-9]|[1-2][0-9]|30|31), ([1-2][0-9]{3})(?=(?:[^\w\/\-%,<][^<]*?|)<\/ref>)", "$1November $2, $3");
ArticleText=Regex.Replace(ArticleText, @"(?i)(<ref[^>]*>(?:[^<]+?[\s\(]|))Dec\.? ([1-9]|[1-2][0-9]|30|31), ([1-2][0-9]{3})(?=(?:[^\w\/\-%,<][^<]*?|)<\/ref>)", "$1December $2, $3");
ArticleText=Regex.Replace(ArticleText, @"(?i)([ ]\()Jan\.? ([1-9]|[1-2][0-9]|30|31), ([1-2][0-9]{3})(?=\)\W)", "$1January $2, $3");
ArticleText=Regex.Replace(ArticleText, @"(?i)([ ]\()Feb\.? ([1-9]|[1-2][0-9]|30|31), ([1-2][0-9]{3})(?=\)\W)", "$1February $2, $3");
ArticleText=Regex.Replace(ArticleText, @"(?i)([ ]\()Mar\.? ([1-9]|[1-2][0-9]|30|31), ([1-2][0-9]{3})(?=\)\W)", "$1March $2, $3");
ArticleText=Regex.Replace(ArticleText, @"(?i)([ ]\()Apr\.? ([1-9]|[1-2][0-9]|30|31), ([1-2][0-9]{3})(?=\)\W)", "$1April $2, $3");
// ArticleText=Regex.Replace(ArticleText, @"(?i)([ ]\()@Month ([1-9]|[1-2][0-9]|30|31), ([1-2][0-9]{3})(?=\)\W)", "$1Fullmonth $2, $3");
ArticleText=Regex.Replace(ArticleText, @"(?i)([ ]\()Jun\.? ([1-9]|[1-2][0-9]|30|31), ([1-2][0-9]{3})(?=\)\W)", "$1June $2, $3");
ArticleText=Regex.Replace(ArticleText, @"(?i)([ ]\()(?:Jly|Jul\.?) ([1-9]|[1-2][0-9]|30|31), ([1-2][0-9]{3})(?=\)\W)", "$1July $2, $3");
ArticleText=Regex.Replace(ArticleText, @"(?i)([ ]\()Aug\.? ([1-9]|[1-2][0-9]|30|31), ([1-2][0-9]{3})(?=\)\W)", "$1August $2, $3");
ArticleText=Regex.Replace(ArticleText, @"(?i)([ ]\()Sep\.? ([1-9]|[1-2][0-9]|30|31), ([1-2][0-9]{3})(?=\)\W)", "$1September $2, $3");
ArticleText=Regex.Replace(ArticleText, @"(?i)([ ]\()Oct\.? ([1-9]|[1-2][0-9]|30|31), ([1-2][0-9]{3})(?=\)\W)", "$1October $2, $3");
ArticleText=Regex.Replace(ArticleText, @"(?i)([ ]\()Nov\.? ([1-9]|[1-2][0-9]|30|31), ([1-2][0-9]{3})(?=\)\W)", "$1November $2, $3");
ArticleText=Regex.Replace(ArticleText, @"(?i)([ ]\()Dec\.? ([1-9]|[1-2][0-9]|30|31), ([1-2][0-9]{3})(?=\)\W)", "$1December $2, $3");
//Slashes
ArticleText=Regex.Replace(ArticleText, @"(?i)([^\w-])(1[3-9]|[2-3]\d)\/0?1\/([12]\d{3})(?![\w\d-])", "$1 January $2, $3");
ArticleText=Regex.Replace(ArticleText, @"(?i)([^\w-])(1[3-9]|[2-3]\d)\/0?2\/([12]\d{3})(?![\w\d-])", "$1 February $2, $3");
ArticleText=Regex.Replace(ArticleText, @"(?i)([^\w-])(1[3-9]|[2-3]\d)\/0?3\/([12]\d{3})(?![\w\d-])", "$1 March $2, $3");
ArticleText=Regex.Replace(ArticleText, @"(?i)([^\w-])(1[3-9]|[2-3]\d)\/0?4\/([12]\d{3})(?![\w\d-])", "$1 April $2, $3");
ArticleText=Regex.Replace(ArticleText, @"(?i)([^\w-])(1[3-9]|[2-3]\d)\/0?5\/([12]\d{3})(?![\w\d-])", "$1 May $2, $3");
ArticleText=Regex.Replace(ArticleText, @"(?i)([^\w-])(1[3-9]|[2-3]\d)\/0?6\/([12]\d{3})(?![\w\d-])", "$1 June $2, $3");
ArticleText=Regex.Replace(ArticleText, @"(?i)([^\w-])(1[3-9]|[2-3]\d)\/0?7\/([12]\d{3})(?![\w\d-])", "$1 July $2, $3");
ArticleText=Regex.Replace(ArticleText, @"(?i)([^\w-])(1[3-9]|[2-3]\d)\/0?8\/([12]\d{3})(?![\w\d-])", "$1 August $2, $3");
ArticleText=Regex.Replace(ArticleText, @"(?i)([^\w-])(1[3-9]|[2-3]\d)\/0?9\/([12]\d{3})(?![\w\d-])", "$1 September $2, $3");
ArticleText=Regex.Replace(ArticleText, @"(?i)([^\w-])(1[3-9]|[2-3]\d)\/10\/([12]\d{3})(?![\w\d-])", "$1 October $2, $3");
ArticleText=Regex.Replace(ArticleText, @"(?i)([^\w-])(1[3-9]|[2-3]\d)\/11\/([12]\d{3})(?![\w\d-])", "$1 November $2, $3");
ArticleText=Regex.Replace(ArticleText, @"(?i)([^\w-])(1[3-9]|[2-3]\d)\/12\/([12]\d{3})(?![\w\d-])", "$1 December $2, $3");
//2-digit year – UK style
ArticleText=Regex.Replace(ArticleText, @"(?i)([^\w-])(1[3-9]|[2-3]\d)\/0?1\/([4-9]\d)(?![\w\d-])", "$1 January $2, 19$3");
ArticleText=Regex.Replace(ArticleText, @"(?i)([^\w-])(1[3-9]|[2-3]\d)\/0?2\/([4-9]\d)(?![\w\d-])", "$1 February $2, 19$3");
ArticleText=Regex.Replace(ArticleText, @"(?i)([^\w-])(1[3-9]|[2-3]\d)\/0?3\/([4-9]\d)(?![\w\d-])", "$1 March $2, 19$3");
ArticleText=Regex.Replace(ArticleText, @"(?i)([^\w-])(1[3-9]|[2-3]\d)\/0?4\/([4-9]\d)(?![\w\d-])", "$1 April $2, 19$3");
ArticleText=Regex.Replace(ArticleText, @"(?i)([^\w-])(1[3-9]|[2-3]\d)\/0?5\/([4-9]\d)(?![\w\d-])", "$1 May $2, 19$3");
ArticleText=Regex.Replace(ArticleText, @"(?i)([^\w-])(1[3-9]|[2-3]\d)\/0?6\/([4-9]\d)(?![\w\d-])", "$1 June $2, 19$3");
ArticleText=Regex.Replace(ArticleText, @"(?i)([^\w-])(1[3-9]|[2-3]\d)\/0?7\/([4-9]\d)(?![\w\d-])", "$1 July $2, 19$3");
ArticleText=Regex.Replace(ArticleText, @"(?i)([^\w-])(1[3-9]|[2-3]\d)\/0?8\/([4-9]\d)(?![\w\d-])", "$1 August $2, 19$3");
ArticleText=Regex.Replace(ArticleText, @"(?i)([^\w-])(1[3-9]|[2-3]\d)\/0?9\/([4-9]\d)(?![\w\d-])", "$1 September $2, 19$3");
ArticleText=Regex.Replace(ArticleText, @"(?i)([^\w-])(1[3-9]|[2-3]\d)\/10\/([4-9]\d)(?![\w\d-])", "$1 October $2, 19$3");
ArticleText=Regex.Replace(ArticleText, @"(?i)([^\w-])(1[3-9]|[2-3]\d)\/11\/([4-9]\d)(?![\w\d-])", "$1 November $2, 19$3");
ArticleText=Regex.Replace(ArticleText, @"(?i)([^\w-])(1[3-9]|[2-3]\d)\/12\/([4-9]\d)(?![\w\d-])", "$1 December $2, 19$3");
ArticleText=Regex.Replace(ArticleText, @"(?i)([^\w-])(1[3-9]|[2-3]\d)\/0?1\/([01]\d)(?![\w\d-])", "$1 January $2, 20$3");
ArticleText=Regex.Replace(ArticleText, @"(?i)([^\w-])(1[3-9]|[2-3]\d)\/0?2\/([01]\d)(?![\w\d-])", "$1 February $2, 20$3");
ArticleText=Regex.Replace(ArticleText, @"(?i)([^\w-])(1[3-9]|[2-3]\d)\/0?3\/([01]\d)(?![\w\d-])", "$1 March $2, 20$3");
ArticleText=Regex.Replace(ArticleText, @"(?i)([^\w-])(1[3-9]|[2-3]\d)\/0?4\/([01]\d)(?![\w\d-])", "$1 April $2, 20$3");
ArticleText=Regex.Replace(ArticleText, @"(?i)([^\w-])(1[3-9]|[2-3]\d)\/0?5\/([01]\d)(?![\w\d-])", "$1 May $2, 20$3");
ArticleText=Regex.Replace(ArticleText, @"(?i)([^\w-])(1[3-9]|[2-3]\d)\/0?6\/([01]\d)(?![\w\d-])", "$1 June $2, 20$3");
ArticleText=Regex.Replace(ArticleText, @"(?i)([^\w-])(1[3-9]|[2-3]\d)\/0?7\/([01]\d)(?![\w\d-])", "$1 July $2, 20$3");
ArticleText=Regex.Replace(ArticleText, @"(?i)([^\w-])(1[3-9]|[2-3]\d)\/0?8\/([01]\d)(?![\w\d-])", "$1 August $2, 20$3");
ArticleText=Regex.Replace(ArticleText, @"(?i)([^\w-])(1[3-9]|[2-3]\d)\/0?9\/([01]\d)(?![\w\d-])", "$1 September $2, 20$3");
ArticleText=Regex.Replace(ArticleText, @"(?i)([^\w-])(1[3-9]|[2-3]\d)\/10\/([01]\d)(?![\w\d-])", "$1 October $2, 20$3");
ArticleText=Regex.Replace(ArticleText, @"(?i)([^\w-])(1[3-9]|[2-3]\d)\/11\/([01]\d)(?![\w\d-])", "$1 November $2, 20$3");
ArticleText=Regex.Replace(ArticleText, @"(?i)([^\w-])(1[3-9]|[2-3]\d)\/12\/([01]\d)(?![\w\d-])", "$1 December $2, 20$3");
//numerical format with hyphens and dashes (dd-mm-yyyy) to mdy
ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([0-2]?\d|30|31)[\-–]0?1[\-–]([1-2]\d{3})(?=\s*[\|\}])", "$1January $2, $3");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([0-2]?\d)[\-–]0?2[\-–]([1-2]\d{3})(?=\s*[\|\}])", "$1February $2, $3");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([0-2]?\d|30|31)[\-–]0?3[\-–]([1-2]\d{3})(?=\s*[\|\}])", "$1March $2, $3");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([0-2]?\d|30|31)[\-–]0?4[\-–]([1-2]\d{3})(?=\s*[\|\}])", "$1April $2, $3");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([0-2]?\d|30|31)[\-–]0?5[\-–]([1-2]\d{3})(?=\s*[\|\}])", "$1May $2, $3");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([0-2]?\d|30|31)[\-–]0?6[\-–]([1-2]\d{3})(?=\s*[\|\}])", "$1June $2, $3");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([0-2]?\d|30|31)[\-–]0?7[\-–]([1-2]\d{3})(?=\s*[\|\}])", "$1July $2, $3");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([0-2]?\d|30|31)[\-–]0?8[\-–]([1-2]\d{3})(?=\s*[\|\}])", "$1August $2, $3");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([0-2]?\d|30|31)[\-–]0?9[\-–]([1-2]\d{3})(?=\s*[\|\}])", "$1September $2, $3");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([0-2]?\d|30|31)[\-–]10[\-–]([1-2]\d{3})(?=\s*[\|\}])", "$1October $2, $3");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([0-2]?\d|30|31)[\-–]11[\-–]([1-2]\d{3})(?=\s*[\|\}])", "$1November $2, $3");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([0-2]?\d|30|31)[\-–]12[\-–]([1-2]\d{3})(?=\s*[\|\}])", "$1December $2, $3");
//improperly formatted access dates with endashes (yyyy–mm–dd) and/or missing zeros to ISO
ArticleText=Regex.Replace(ArticleText, @"(?i)(\|[ ]*accessdate[ ]*=[ ]*)([1-2]\d{3})[–—]([0-2]?\d)[–—]([0-2]?\d|30|31)(?=\s*[\|\}])", "$1$2-$3-$4"); //ndashes and emdashes
ArticleText=Regex.Replace(ArticleText, @"(?i)(\|[ ]*accessdate[ ]*=[ ]*)([1-2]\d{3})-(\d)-([0-2]\d|30|31)(?=\s*[\|\}])", "$1$2-0$3-$4"); //ndashes and emdashes
ArticleText=Regex.Replace(ArticleText, @"(?i)(\|[ ]*accessdate[ ]*=[ ]*)([1-2]\d{3})-([0-1]\d)-(\d)(?=\s*[\|\}])", "$1$2-$3-0$4"); //ndashes and emdashes
ArticleText=Regex.Replace(ArticleText, @"(?i)(\|[ ]*accessdate[ ]*=[ ]*)([1-2]\d{3})-(\d)-(\d)(?=\s*[\|\}])", "$1$2-0$3-0$4"); //ndashes and emdashes
//improperly formatted dates with endashes (yyyy–mm–dd) and/or missing zeros to dmy
ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([1-2]\d{3})–0?1–([0-2]?\d|30|31)(?=\s*[\|\}])", "$1January $3, $2");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([1-2]\d{3})–0?2–([0-2]?\d)(?=\s*[\|\}])", "$1February $3, $2");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([1-2]\d{3})–0?3–([0-2]?\d|30|31)(?=\s*[\|\}])", "$1March $3, $2");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([1-2]\d{3})–0?4–([0-2]?\d|30|31)(?=\s*[\|\}])", "$1April $3, $2");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([1-2]\d{3})–0?5–([0-2]?\d|30|31)(?=\s*[\|\}])", "$1May $3, $2");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([1-2]\d{3})–0?6–([0-2]?\d|30|31)(?=\s*[\|\}])", "$1June $3, $2");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([1-2]\d{3})–0?7–([0-2]?\d|30|31)(?=\s*[\|\}])", "$1July $3, $2");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([1-2]\d{3})–0?8–([0-2]?\d|30|31)(?=\s*[\|\}])", "$1August $3, $2");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([1-2]\d{3})–0?9–([0-2]?\d|30|31)(?=\s*[\|\}])", "$1September $3, $2");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([1-2]\d{3})–10–([0-2]?\d|30|31)(?=\s*[\|\}])", "$1October $3, $2");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([1-2]\d{3})–11–([0-2]?\d|30|31)(?=\s*[\|\}])", "$1November $3, $2");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([1-2]\d{3})–12–([0-2]?\d|30|31)(?=\s*[\|\}])", "$1December $3, $2");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([1-2]\d{3})[\-–]0?1[\-–]([1-9])(?=\s*[\|\}])", "$1January $3, $2");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([1-2]\d{3})[\-–]0?2[\-–]([1-9])(?=\s*[\|\}])", "$1February $3, $2");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([1-2]\d{3})[\-–]0?3[\-–]([1-9])(?=\s*[\|\}])", "$1March $3, $2");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([1-2]\d{3})[\-–]0?4[\-–]([1-9])(?=\s*[\|\}])", "$1April $3, $2");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([1-2]\d{3})[\-–]0?5[\-–]([1-9])(?=\s*[\|\}])", "$1May $3, $2");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([1-2]\d{3})[\-–]0?6[\-–]([1-9])(?=\s*[\|\}])", "$1June $3, $2");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([1-2]\d{3})[\-–]0?7[\-–]([1-9])(?=\s*[\|\}])", "$1July $3, $2");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([1-2]\d{3})[\-–]0?8[\-–]([1-9])(?=\s*[\|\}])", "$1August $3, $2");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([1-2]\d{3})[\-–]0?9[\-–]([1-9])(?=\s*[\|\}])", "$1September $3, $2");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([1-2]\d{3})[\-–]10[\-–]([1-9])(?=\s*[\|\}])", "$1October $3, $2");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([1-2]\d{3})[\-–]11[\-–]([1-9])(?=\s*[\|\}])", "$1November $3, $2");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([1-2]\d{3})[\-–]12[\-–]([1-9])(?=\s*[\|\}])", "$1December $3, $2");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([1-2]\d{3})[\-–]1[\-–]([0-2]?\d|30|31)(?=\s*[\|\}])", "$1January $3, $2");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([1-2]\d{3})[\-–]2[\-–](0?[1-9]|[1-2]\d)(?=\s*[\|\}])", "$1February $3, $2");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([1-2]\d{3})[\-–]3[\-–]([0-2]?\d|30|31)(?=\s*[\|\}])", "$1March $3, $2");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([1-2]\d{3})[\-–]4[\-–]([0-2]?\d|30|31)(?=\s*[\|\}])", "$1April $3, $2");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([1-2]\d{3})[\-–]5[\-–]([0-2]?\d|30|31)(?=\s*[\|\}])", "$1May $3, $2");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([1-2]\d{3})[\-–]6[\-–]([0-2]?\d|30|31)(?=\s*[\|\}])", "$1June $3, $2");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([1-2]\d{3})[\-–]7[\-–]([0-2]?\d|30|31)(?=\s*[\|\}])", "$1July $3, $2");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([1-2]\d{3})[\-–]8[\-–]([0-2]?\d|30|31)(?=\s*[\|\}])", "$1August $3, $2");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([1-2]\d{3})[\-–]9[\-–]([0-2]?\d|30|31)(?=\s*[\|\}])", "$1September $3, $2");
//ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([1-2]\d{3})[\-–]10[\-–]([0-2]?\d|30|31)(?=\s*[\|\}])", "$1October $3, $2");
//ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([1-2]\d{3})[\-–]11[\-–]([0-2]?\d|30|31)(?=\s*[\|\}])", "$1November $3, $2");
//ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([1-2]\d{3})[\-–]12[\-–]([0-2]?\d|30|31)(?=\s*[\|\}])", "$1December $3, $2");
//yyyymmdd_to_dmy
ArticleText=Regex.Replace(ArticleText, @"(?i)(\|[ ]*(?:archive|)date[ ]*=[ ]*)(?:\[\[)?([1-2][0-9]{3})(?:\]\]-\[\[|-)0?1-(0[1-9]|[1-2][0-9]|30|31)(?:\]\])?", "$1January $3, $2");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\|[ ]*(?:archive|)date[ ]*=[ ]*)(?:\[\[)?([1-2][0-9]{3})(?:\]\]-\[\[|-)0?2-(0[1-9]|[1-2][0-9]|30|31)(?:\]\])?", "$1February $3, $2");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\|[ ]*(?:archive|)date[ ]*=[ ]*)(?:\[\[)?([1-2][0-9]{3})(?:\]\]-\[\[|-)0?3-(0[1-9]|[1-2][0-9]|30|31)(?:\]\])?", "$1March $3, $2");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\|[ ]*(?:archive|)date[ ]*=[ ]*)(?:\[\[)?([1-2][0-9]{3})(?:\]\]-\[\[|-)0?4-(0[1-9]|[1-2][0-9]|30|31)(?:\]\])?", "$1April $3, $2");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\|[ ]*(?:archive|)date[ ]*=[ ]*)(?:\[\[)?([1-2][0-9]{3})(?:\]\]-\[\[|-)0?5-(0[1-9]|[1-2][0-9]|30|31)(?:\]\])?", "$1May $3, $2");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\|[ ]*(?:archive|)date[ ]*=[ ]*)(?:\[\[)?([1-2][0-9]{3})(?:\]\]-\[\[|-)0?6-(0[1-9]|[1-2][0-9]|30|31)(?:\]\])?", "$1June $3, $2");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\|[ ]*(?:archive|)date[ ]*=[ ]*)(?:\[\[)?([1-2][0-9]{3})(?:\]\]-\[\[|-)0?7-(0[1-9]|[1-2][0-9]|30|31)(?:\]\])?", "$1July $3, $2");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\|[ ]*(?:archive|)date[ ]*=[ ]*)(?:\[\[)?([1-2][0-9]{3})(?:\]\]-\[\[|-)0?8-(0[1-9]|[1-2][0-9]|30|31)(?:\]\])?", "$1August $3, $2");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\|[ ]*(?:archive|)date[ ]*=[ ]*)(?:\[\[)?([1-2][0-9]{3})(?:\]\]-\[\[|-)0?9-(0[1-9]|[1-2][0-9]|30|31)(?:\]\])?", "$1September $3, $2");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\|[ ]*(?:archive|)date[ ]*=[ ]*)(?:\[\[)?([1-2][0-9]{3})(?:\]\]-\[\[|-)10-(0[1-9]|[1-2][0-9]|30|31)(?:\]\])?", "$1October $3, $2");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\|[ ]*(?:archive|)date[ ]*=[ ]*)(?:\[\[)?([1-2][0-9]{3})(?:\]\]-\[\[|-)11-(0[1-9]|[1-2][0-9]|30|31)(?:\]\])?", "$1November $3, $2");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\|[ ]*(?:archive|)date[ ]*=[ ]*)(?:\[\[)?([1-2][0-9]{3})(?:\]\]-\[\[|-)12-(0[1-9]|[1-2][0-9]|30|31)(?:\]\])?", "$1December $3, $2");
ArticleText=Regex.Replace(ArticleText, @"(?i)(date[ ]*=[ ]*)(0[1-9]|[1-2][0-9]|30|31)-0?1-([1-2][0-9]{3})?", "$1January $2, $3");
ArticleText=Regex.Replace(ArticleText, @"(?i)(date[ ]*=[ ]*)(0[1-9]|[1-2][0-9])-0?2-([1-2][0-9]{3})?", "$1February $2, $3");
ArticleText=Regex.Replace(ArticleText, @"(?i)(date[ ]*=[ ]*)(0[1-9]|[1-2][0-9]|30|31)-0?3-([1-2][0-9]{3})?", "$1March $2, $3");
ArticleText=Regex.Replace(ArticleText, @"(?i)(date[ ]*=[ ]*)(0[1-9]|[1-2][0-9]|30|31)-0?4-([1-2][0-9]{3})?", "$1April $2, $3");
ArticleText=Regex.Replace(ArticleText, @"(?i)(date[ ]*=[ ]*)(0[1-9]|[1-2][0-9]|30|31)-0?5-([1-2][0-9]{3})?", "$1May $2, $3");
ArticleText=Regex.Replace(ArticleText, @"(?i)(date[ ]*=[ ]*)(0[1-9]|[1-2][0-9]|30|31)-0?6-([1-2][0-9]{3})?", "$1June $2, $3");
ArticleText=Regex.Replace(ArticleText, @"(?i)(date[ ]*=[ ]*)(0[1-9]|[1-2][0-9]|30|31)-0?7-([1-2][0-9]{3})?", "$1July $2, $3");
ArticleText=Regex.Replace(ArticleText, @"(?i)(date[ ]*=[ ]*)(0[1-9]|[1-2][0-9]|30|31)-0?8-([1-2][0-9]{3})?", "$1August $2, $3");
ArticleText=Regex.Replace(ArticleText, @"(?i)(date[ ]*=[ ]*)(0[1-9]|[1-2][0-9]|30|31)-0?9-([1-2][0-9]{3})?", "$1September $2, $3");
ArticleText=Regex.Replace(ArticleText, @"(?i)(date[ ]*=[ ]*)(0[1-9]|[1-2][0-9]|30|31)-10-([1-2][0-9]{3})?", "$1October $2, $3");
ArticleText=Regex.Replace(ArticleText, @"(?i)(date[ ]*=[ ]*)(0[1-9]|[1-2][0-9]|30|31)-11-([1-2][0-9]{3})?", "$1November $2, $3");
ArticleText=Regex.Replace(ArticleText, @"(?i)(date[ ]*=[ ]*)(0[1-9]|[1-2][0-9]|30|31)-12-([1-2][0-9]{3})?", "$1December $2, $3");
ArticleText=Regex.Replace(ArticleText, @"(?i)(date[ ]*=[ ]*)([1-2][0-9]{3}) (January )(0[1-9]|[1-2][0-9]|30|31)", "$1$3$4, $2");
ArticleText=Regex.Replace(ArticleText, @"(?i)(date[ ]*=[ ]*)([1-2][0-9]{3}) (February )(0[1-9]|[1-2][0-9])", "$1$3$4, $2");
ArticleText=Regex.Replace(ArticleText, @"(?i)(date[ ]*=[ ]*)([1-2][0-9]{3}) (March )(0[1-9]|[1-2][0-9]|30|31)", "$1$3$4, $2");
ArticleText=Regex.Replace(ArticleText, @"(?i)(date[ ]*=[ ]*)([1-2][0-9]{3}) (April )(0[1-9]|[1-2][0-9]|30|31)", "$1$3$4, $2");
ArticleText=Regex.Replace(ArticleText, @"(?i)(date[ ]*=[ ]*)([1-2][0-9]{3}) (May )(0[1-9]|[1-2][0-9]|30|31)", "$1$3$4, $2");
ArticleText=Regex.Replace(ArticleText, @"(?i)(date[ ]*=[ ]*)([1-2][0-9]{3}) (June )(0[1-9]|[1-2][0-9]|30|31)", "$1$3$4, $2");
ArticleText=Regex.Replace(ArticleText, @"(?i)(date[ ]*=[ ]*)([1-2][0-9]{3}) (July )(0[1-9]|[1-2][0-9]|30|31)", "$1$3$4, $2");
ArticleText=Regex.Replace(ArticleText, @"(?i)(date[ ]*=[ ]*)([1-2][0-9]{3}) (August )(0[1-9]|[1-2][0-9]|30|31)", "$1$3$4, $2");
ArticleText=Regex.Replace(ArticleText, @"(?i)(date[ ]*=[ ]*)([1-2][0-9]{3}) (September )(0[1-9]|[1-2][0-9]|30|31)", "$1$3$4, $2");
ArticleText=Regex.Replace(ArticleText, @"(?i)(date[ ]*=[ ]*)([1-2][0-9]{3}) (October )(0[1-9]|[1-2][0-9]|30|31)", "$1$3$4, $2");
ArticleText=Regex.Replace(ArticleText, @"(?i)(date[ ]*=[ ]*)([1-2][0-9]{3}) (November )(0[1-9]|[1-2][0-9]|30|31)", "$1$3$4, $2");
ArticleText=Regex.Replace(ArticleText, @"(?i)(date[ ]*=[ ]*)([1-2][0-9]{3}) (December )(0[1-9]|[1-2][0-9]|30|31)", "$1$3$4, $2");
ArticleText=Regex.Replace(ArticleText, @"(?i)([^\d\w\/\-%,])([12]\d{3}-\d\d-\d\d)(<\s?\/ref.*?>)", "$1$2 $3");
//code to convert ref ISO-dates outside citation templates
ArticleText=Regex.Replace(ArticleText, @"(?i)(<ref.*?>[^<]+?)(\s\()([12]\d{3})-01-0(\d)(\)[^\w\/\-%,])([^<]*?<\s?\/ref.*?>)", "$1$2January $4, $3$5$6");
ArticleText=Regex.Replace(ArticleText, @"(?i)(<ref.*?>[^<]+?)(\s\()([12]\d{3})-02-0(\d)(\)[^\w\/\-%,])([^<]*?<\s?\/ref.*?>)", "$1$2February $4, $3$5$6");
ArticleText=Regex.Replace(ArticleText, @"(?i)(<ref.*?>[^<]+?)(\s\()([12]\d{3})-03-0(\d)(\)[^\w\/\-%,])([^<]*?<\s?\/ref.*?>)", "$1$2March $4, $3$5$6");
ArticleText=Regex.Replace(ArticleText, @"(?i)(<ref.*?>[^<]+?)(\s\()([12]\d{3})-04-0(\d)(\)[^\w\/\-%,])([^<]*?<\s?\/ref.*?>)", "$1$2April $4, $3$5$6");
ArticleText=Regex.Replace(ArticleText, @"(?i)(<ref.*?>[^<]+?)(\s\()([12]\d{3})-05-0(\d)(\)[^\w\/\-%,])([^<]*?<\s?\/ref.*?>)", "$1$2May $4, $3$5$6");
ArticleText=Regex.Replace(ArticleText, @"(?i)(<ref.*?>[^<]+?)(\s\()([12]\d{3})-06-0(\d)(\)[^\w\/\-%,])([^<]*?<\s?\/ref.*?>)", "$1$2June $4, $3$5$6");
ArticleText=Regex.Replace(ArticleText, @"(?i)(<ref.*?>[^<]+?)(\s\()([12]\d{3})-07-0(\d)(\)[^\w\/\-%,])([^<]*?<\s?\/ref.*?>)", "$1$2July $4, $3$5$6");
ArticleText=Regex.Replace(ArticleText, @"(?i)(<ref.*?>[^<]+?)(\s\()([12]\d{3})-08-0(\d)(\)[^\w\/\-%,])([^<]*?<\s?\/ref.*?>)", "$1$2August $4, $3$5$6");
ArticleText=Regex.Replace(ArticleText, @"(?i)(<ref.*?>[^<]+?)(\s\()([12]\d{3})-09-0(\d)(\)[^\w\/\-%,])([^<]*?<\s?\/ref.*?>)", "$1$2September $4, $3$5$6");
ArticleText=Regex.Replace(ArticleText, @"(?i)(<ref.*?>[^<]+?)(\s\()([12]\d{3})-10-0(\d)(\)[^\w\/\-%,])([^<]*?<\s?\/ref.*?>)", "$1$2October $4, $3$5$6");
ArticleText=Regex.Replace(ArticleText, @"(?i)(<ref.*?>[^<]+?)(\s\()([12]\d{3})-11-0(\d)(\)[^\w\/\-%,])([^<]*?<\s?\/ref.*?>)", "$1$2November $4, $3$5$6");
ArticleText=Regex.Replace(ArticleText, @"(?i)(<ref.*?>[^<]+?)(\s\()([12]\d{3})-12-0(\d)(\)[^\w\/\-%,])([^<]*?<\s?\/ref.*?>)", "$1$2December $4, $3$5$6");
ArticleText=Regex.Replace(ArticleText, @"(?i)(<ref.*?>[^<]+?)(\s\()([12]\d{3})-01-([1-3]\d)(\)[^\w\/\-%,])([^<]*?<\s?\/ref.*?>)", "$1$2January $4, $3$5$6");
ArticleText=Regex.Replace(ArticleText, @"(?i)(<ref.*?>[^<]+?)(\s\()([12]\d{3})-02-([1-3]\d)(\)[^\w\/\-%,])([^<]*?<\s?\/ref.*?>)", "$1$2February $4, $3$5$6");
ArticleText=Regex.Replace(ArticleText, @"(?i)(<ref.*?>[^<]+?)(\s\()([12]\d{3})-03-([1-3]\d)(\)[^\w\/\-%,])([^<]*?<\s?\/ref.*?>)", "$1$2March $4, $3$5$6");
ArticleText=Regex.Replace(ArticleText, @"(?i)(<ref.*?>[^<]+?)(\s\()([12]\d{3})-04-([1-3]\d)(\)[^\w\/\-%,])([^<]*?<\s?\/ref.*?>)", "$1$2April $4, $3$5$6");
ArticleText=Regex.Replace(ArticleText, @"(?i)(<ref.*?>[^<]+?)(\s\()([12]\d{3})-05-([1-3]\d)(\)[^\w\/\-%,])([^<]*?<\s?\/ref.*?>)", "$1$2May $4, $3$5$6");
ArticleText=Regex.Replace(ArticleText, @"(?i)(<ref.*?>[^<]+?)(\s\()([12]\d{3})-06-([1-3]\d)(\)[^\w\/\-%,])([^<]*?<\s?\/ref.*?>)", "$1$2June $4, $3$5$6");
ArticleText=Regex.Replace(ArticleText, @"(?i)(<ref.*?>[^<]+?)(\s\()([12]\d{3})-07-([1-3]\d)(\)[^\w\/\-%,])([^<]*?<\s?\/ref.*?>)", "$1$2July $4, $3$5$6");
ArticleText=Regex.Replace(ArticleText, @"(?i)(<ref.*?>[^<]+?)(\s\()([12]\d{3})-08-([1-3]\d)(\)[^\w\/\-%,])([^<]*?<\s?\/ref.*?>)", "$1$2August $4, $3$5$6");
ArticleText=Regex.Replace(ArticleText, @"(?i)(<ref.*?>[^<]+?)(\s\()([12]\d{3})-09-([1-3]\d)(\)[^\w\/\-%,])([^<]*?<\s?\/ref.*?>)", "$1$2September $4, $3$5$6");
ArticleText=Regex.Replace(ArticleText, @"(?i)(<ref.*?>[^<]+?)(\s\()([12]\d{3})-10-([1-3]\d)(\)[^\w\/\-%,])([^<]*?<\s?\/ref.*?>)", "$1$2October $4, $3$5$6");
ArticleText=Regex.Replace(ArticleText, @"(?i)(<ref.*?>[^<]+?)(\s\()([12]\d{3})-11-([1-3]\d)(\)[^\w\/\-%,])([^<]*?<\s?\/ref.*?>)", "$1$2November $4, $3$5$6");
ArticleText=Regex.Replace(ArticleText, @"(?i)(<ref.*?>[^<]+?)(\s\()([12]\d{3})-12-([1-3]\d)(\)[^\w\/\-%,])([^<]*?<\s?\/ref.*?>)", "$1$2December $4, $3$5$6");
//convert dm-dmy date ranges to md-mdy
ArticleText=Regex.Replace(ArticleText, @"(?i)(\D\W)([0-2]?\d|30|31)(?:th|st|nd|rd|)((?:,?\s[0-3]?\d(?:th|st|nd|rd|)){0,6}),?(\/|\s?(?:[-–]|–)\s?|\s(?:and|to|&)\s)([0-2]?\d|30|31)(?:th|st|nd|rd|) (Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|)),?\s(?:of\s|)(\d{3,4}\W\D)", "$1$6 $2$3$4$5, $7");
//test code ArticleText=Regex.Replace(ArticleText, @"(?i)(\D\W)([0-2]?\d|30|31)(?:th|st|nd|rd|)((?:,?\s[0-3]?\d(?:th|st|nd|rd|)){0,6}),? ([0-2]?\d|30|31)(?:th|st|nd|rd|)\s(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|)),?\s(?:of\s)?(\d{3,4}\W\D)", "$1$5 $2$3$4, $6");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\D\W)([0-2]?\d|30|31)(?:th|st|nd|rd|)((?:,?\s[0-3]?\d(?:th|st|nd|rd|)){0,6}), ([0-2]?\d|30|31)(?:th|st|nd|rd|)\s(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))(?=\W\D|[ ]*\r)", "$1$5 $2$3$4");
//convert d,d,dm date ranges to md,d,d, (multiple, separated by commas)
ArticleText=Regex.Replace(ArticleText, @"(?i)(\D\W)([1-2]?\d|30|31)(?:th|st|nd|rd|)((?:,?\s[0-3]?\d(?:th|st|nd|rd|)){0,6}),?(\/|\s?(?:[-–]|–)\s?|\s(?:and|to|&)\s)([0-2]?\d|30|31)(?:th|st|nd|rd|)\s(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))(?=\W\D|[ ]*\r)", "$1$6 $2$3$4$5");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\D\W)((?:[1-3]?\d(?:th|st|nd|rd|),?\s){1,6})((?:and|to|&|–)\s)([0-2]?\d|30|31)(?:th|st|nd|rd|)\s(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))(?=\W\D|[ ]*\r)", "$1$5 $2$3$4");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\D\W)([1-2]?\d|30|31)(?:th|st|nd|rd|)((?:,?\s[1-3]?\d(?:th|st|nd|rd|)){1,6})\s(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))(?=\W\D|[ ]*\r)", "$1$4 $2$3");
//convert md date ranges to dm (simple, separated by hyphens and dashes or 'to')
ArticleText=Regex.Replace(ArticleText, @"(?i)(\D\W)([1-2]?\d|30|31)(?:th|st|nd|rd|)(\s?(?:[-–]|–)\s?|\sto\s)(?:\2\s|)([0-2]?\d|30|31)(?:th|st|nd|rd|)\s(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))(?=\W\D|[ ]*\r)", "$1$5 $2$3$4");
// 'dm, dm,' to 'md, md,'
ArticleText=Regex.Replace(ArticleText, @"(?i)(\D)([0-2]?\d|30|31)\s(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|)),( [0-2]?\d|30|31) (Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))([,\.]\W\D)", "$1$3 $2, $5 $4$6");
//convert simple mdy dates to dmy
ArticleText=Regex.Replace(ArticleText, @"(?i)(\D\W)([0-2]?\d|30|31)(?:th|st|nd|rd|)\s(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|)),?\s(\d{1,4}\s?(?:AD|BC|CE|BCE)\W\D)", "$1$3 $2, $4");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\D\W)([0-2]?\d|30|31)(?:th|st|nd|rd|)\s(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|)),?\s([12]\d{3})(?=\W\D|[ ]*\r)", "$1$3 $2, $4");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\D\W)([0-2]?\d|30|31)(?:th|st|nd|rd|)\s(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))(?=\W\D|[ ]*\r)", "$1$3 $2");
//Month+day_number "March 7th" -> "March 7"
ArticleText=Regex.Replace(ArticleText, @"(?i)(\D\W)(Jan(?:uary|.)|Feb(?:ruary|.)|Mar(?:ch|.)|Apr(?:il|.)|May|June?|July?|Aug(?:ust|.)|Sep(?:tember|.)|Oct(?:ober|.)|Nov(?:ember|.)|Dec(?:ember|.))\s([0-2]?\d|30|31)(?:th|st|nd|rd|)(\W\D)", "$1$2 $3$4");
//year
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[([12]?\d{1,3})\]\]", "$1");
//remove leading zero from nonlinked date
ArticleText=Regex.Replace(ArticleText, @"(?i)(\D\W)0(\d)(?:th|st|nd|rd|)\s(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))\s(\d{4})(?=\W\D|[ ]*\r)", "$1$3 $2, $4");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\D\W)0(\d)(?:th|st|nd|rd|)\s(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))(?=\W\D|[ ]*\r)", "$1$3 $2");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\D\W)(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))\s0(\d)(?:th|st|nd|rd|),\s(\d{4})(?=\W\D|[ ]*\r)", "$1$2 $3, $4");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\D\W)(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))0(\d)(?:th|st|nd|rd|)(?=\W\D|[ ]*\r)", "$1$2 $3");
//rem duplicated months in date formats //code not functioning as intended
ArticleText=Regex.Replace(ArticleText, @"(?i)(Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|June?|July?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)\s([1-2]?\d|30|31)(?:th|st|nd|rd|)\s+(to|[\-–—])\s\1\s+([1-2]?\d|30|31)(?:th|st|nd|rd|)(?=\W)", "$1 $2 $3 $4");
//rem ordinals and redundant spaces (and commas) in date ranges
ArticleText=Regex.Replace(ArticleText, @"(?i)(\D)(Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|June?|July?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)\s0?([1-2]?\d|30|31)(?:th|st|nd|rd|)\s+(to|[\-–—])\s+0?([1-2]?\d|30|31)(?:th|st|nd|rd|)(?=\W)", "$1$2 $3 $4 $5");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\D)(Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|June?|July?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)\s0?([1-2]?\d|30|31)(?:th|st|nd|rd|),\s?(\d{3,4})(?=\W)", "$1$2 $3, $4");
//replace 'as of [date]' with 'updated [date]'
ArticleText=Regex.Replace(ArticleText, @"(?i)(\'\')As of\s([0-2]?\d|30|31)\s(Jan(?:uary|.)|Feb(?:ruary|.)|Mar(?:ch|.)|Apr(?:il|.)|May|June?|July?|Aug(?:ust|.)|Sep(?:tember|.)|Oct(?:ober|.)|Nov(?:ember|.)|Dec(?:ember|.)),\s?(20\d{2})(?=\.?\')", "$1Updated $3 $2, $4");
//remove Crores and Lakhs in templates converting to USD
ArticleText=Regex.Replace(ArticleText, @"\{\{INR Convert[ ]*\|[ ]*", "{{INRConvert|"); //removing spaces (redirects to shortcut)
ArticleText=Regex.Replace(ArticleText, @"(\{INRConvert\|-?\d{2,})8\.[5-9]\d*[ ]*(\|c(?:\|-?\d|)\}\})", "${1}9$2");
ArticleText=Regex.Replace(ArticleText, @"(\{INRConvert\|-?\d{2,})7\.[5-9]\d*[ ]*(\|c(?:\|-?\d|)\}\})", "${1}8$2");
ArticleText=Regex.Replace(ArticleText, @"(\{INRConvert\|-?\d{2,})6\.[5-9]\d*[ ]*(\|c(?:\|-?\d|)\}\})", "${1}7$2");
ArticleText=Regex.Replace(ArticleText, @"(\{INRConvert\|-?\d{2,})5\.[5-9]\d*[ ]*(\|c(?:\|-?\d|)\}\})", "${1}6$2");
ArticleText=Regex.Replace(ArticleText, @"(\{INRConvert\|-?\d{2,})4\.[5-9]\d*[ ]*(\|c(?:\|-?\d|)\}\})", "${1}5$2");
ArticleText=Regex.Replace(ArticleText, @"(\{INRConvert\|-?\d{2,})3\.[5-9]\d*[ ]*(\|c(?:\|-?\d|)\}\})", "${1}4$2");
ArticleText=Regex.Replace(ArticleText, @"(\{INRConvert\|-?\d{2,})2\.[5-9]\d*[ ]*(\|c(?:\|-?\d|)\}\})", "${1}3$2");
ArticleText=Regex.Replace(ArticleText, @"(\{INRConvert\|-?\d{2,})1\.[5-9]\d*[ ]*(\|c(?:\|-?\d|)\}\})", "${1}2$2");
ArticleText=Regex.Replace(ArticleText, @"(\{INRConvert\|-?\d{2,})0\.[5-9]\d*[ ]*(\|c(?:\|-?\d|)\}\})", "${1}1$2");
ArticleText=Regex.Replace(ArticleText, @"(\{INRConvert\|-?\d{3,})\.[0-4]\d*[ ]*(\|c(?:\|-?\d|)\}\})", "$1$2");
ArticleText=Regex.Replace(ArticleText, @"(\{INRConvert\|)(-?\d+)0000[ ]*\|l(\|-?\d|)(?:\|nolink=yes|)((?:\|year=\d{4}|)\}\})", "$1$2|b$3$4");
ArticleText=Regex.Replace(ArticleText, @"(\{INRConvert\|)(-?\d+)(\d\d)[0-4][ ]*\|l(\|-?\d|)(?:\|nolink=yes|)((?:\|year=\d{4}|)\}\})", "$1$2$3|m$3$4");
ArticleText=Regex.Replace(ArticleText, @"(\{INRConvert\|)(-?\d{2,})[0-4][ ]*\|l(\|-?\d|)(?:\|nolink=yes|)((?:\|year=\d{4}|)\}\})", "$1$2|m$3$4");
ArticleText=Regex.Replace(ArticleText, @"(\{INRConvert\|)(-?\d+)0[ ]*\|l(\|-?\d|)(?:\|nolink=yes|)((?:\|year=\d{4}|)\}\})", "$1$2|m$3$4");
ArticleText=Regex.Replace(ArticleText, @"(\{INRConvert\|)(-?\d+)(\d)[ ]*\|l(\|-?\d|)(?:\|nolink=yes|)((?:\|year=\d{4}|)\}\})", "$1$2.$3|m$4$5");
ArticleText=Regex.Replace(ArticleText, @"(\{INRConvert\|)(-?\d+)[ ]*\|l(\|-?\d|)(?:\|nolink=yes|)((?:\|year=\d{4}|)\}\})", "$1${2}00000$3$4");
ArticleText=Regex.Replace(ArticleText, @"(\{INRConvert\|)(-?\d+)\.(\d)0?[ ]*\|l(\|-?\d|)(?:\|nolink=yes|)((?:\|year=\d{4}|)\}\})", "$1$2${3}0000$4$5");
ArticleText=Regex.Replace(ArticleText, @"(\{INRConvert\|)(-?\d+)\.(\d)(\d)[ ]*\|l(\|-?\d|)(?:\|nolink=yes|)((?:\|year=\d{4}|)\}\})", "$1$2$3${4}000$5$6");
// ArticleText=Regex.Replace(ArticleText, @"(\{INRConvert\|)(-?\d+)(\d)[ ]*\|l(\|-?\d|)(?:\|nolink=yes|)((?:\|year=\d{4}|)\}\})", "$1$2.$3|m$4$5");
ArticleText=Regex.Replace(ArticleText, @"(\{INRConvert\|)(-?\d+)\.(\d)[ ]*\|c(\|-?\d|)(?:\|nolink=yes|)((?:\|year=\d{4}|)\}\})", "$1$2$3|m$4$5");
ArticleText=Regex.Replace(ArticleText, @"(\{INRConvert\|)(-?\d+)\.(\d)(\d+)[ ]*\|c(\|-?\d|)(?:\|nolink=yes|)((?:\|year=\d{4}|)\}\})", "$1$2$3.$4|m$5$6");
ArticleText=Regex.Replace(ArticleText, @"(\{INRConvert\|)(-?\d+)0[0-4][ ]*\|c(\|-?\d|)(?:\|nolink=yes|)((?:\|year=\d{4}|)\}\})", "$1$2|b$3$4");
ArticleText=Regex.Replace(ArticleText, @"(\{INRConvert\|)(-?\d+)(\d)0[ ]*\|c(\|-?\d|)(?:\|nolink=yes|)((?:\|year=\d{4}|)\}\})", "$1$2.$3|b$4$5");
ArticleText=Regex.Replace(ArticleText, @"(\{INRConvert\|)(-?\d{3,})([0-4]\d)[ ]*\|c(\|-?\d|)(?:\|nolink=yes|)((?:\|year=\d{4}|)\}\})", "$1$2|b$4$5");
ArticleText=Regex.Replace(ArticleText, @"(\{INRConvert\|)(-?\d+)(\d\d)[ ]*\|c(\|-?\d|)(?:\|nolink=yes|)((?:\|year=\d{4}|)\}\})", "$1$2.$3|b$4$5");
ArticleText=Regex.Replace(ArticleText, @"(\{INRConvert\|)(-?\d+)[ ]*\|c(\|-?\d|)(?:\|nolink=yes|)((?:\|year=\d{4}|)\}\})", "$1${2}0|m$3$4");
ArticleText=Regex.Replace(ArticleText, @"(\{INRConvert\|-?\d{2,})8\.[5-9]\d*[ ]*(\|[bm](?:\|-?\d|)\}\})", "${1}9$2");
ArticleText=Regex.Replace(ArticleText, @"(\{INRConvert\|-?\d{2,})7\.[5-9]\d*[ ]*(\|[bm](?:\|-?\d|)\}\})", "${1}8$2");
ArticleText=Regex.Replace(ArticleText, @"(\{INRConvert\|-?\d{2,})6\.[5-9]\d*[ ]*(\|[bm](?:\|-?\d|)\}\})", "${1}7$2");
ArticleText=Regex.Replace(ArticleText, @"(\{INRConvert\|-?\d{2,})5\.[5-9]\d*[ ]*(\|[bm](?:\|-?\d|)\}\})", "${1}6$2");
ArticleText=Regex.Replace(ArticleText, @"(\{INRConvert\|-?\d{2,})4\.[5-9]\d*[ ]*(\|[bm](?:\|-?\d|)\}\})", "${1}5$2");
ArticleText=Regex.Replace(ArticleText, @"(\{INRConvert\|-?\d{2,})3\.[5-9]\d*[ ]*(\|[bm](?:\|-?\d|)\}\})", "${1}4$2");
ArticleText=Regex.Replace(ArticleText, @"(\{INRConvert\|-?\d{2,})2\.[5-9]\d*[ ]*(\|[bm](?:\|-?\d|)\}\})", "${1}3$2");
ArticleText=Regex.Replace(ArticleText, @"(\{INRConvert\|-?\d{2,})1\.[5-9]\d*[ ]*(\|[bm](?:\|-?\d|)\}\})", "${1}2$2");
ArticleText=Regex.Replace(ArticleText, @"(\{INRConvert\|-?\d{2,})0\.[5-9]\d*[ ]*(\|[bm](?:\|-?\d|)\}\})", "${1}1$2");
ArticleText=Regex.Replace(ArticleText, @"(\{INRConvert\|-?\d{3,})\.[0-4]\d*[ ]*(\|[bm](?:\|-?\d|)\}\})", "$1$2");
//remove Crores and Lahks not in templates
ArticleText=Regex.Replace(ArticleText, @"(?i)(\d+)[ ]?(?:lakh|\[\[lakh\]\])[\- ](?:crores?|\[\[crores?\]\])", "$1 trillion ([[Long and short scales|short scale]])");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\d+)(\d),?(\d)\d{2}(?:\.\d{,2}|)[ ]?(?:lacs?\b|lakhs?\b|\[\[lakh(?:\|l|\|lac|)\]\]s?)", "$1.$2$3 billion");
ArticleText=Regex.Replace(ArticleText, @"(?i)(?:(\d+),|)(\d{2,})(\d)(?:\.[0-4]\d|)[ ]?(?:lacs?\b|lakhs?\b|\[\[lakh(?:\|l|\|lac|)\]\]s?)", "$1$2.$3 million");
ArticleText=Regex.Replace(ArticleText, @"(?i)(?:(\d+),|)(\d+)\.(\d)[ ]?(?:lacs?\b|lakhs?\b|\[\[lakh(?:\|l|\|lac|)\]\]s?)", "$1$2${3}0,000");
ArticleText=Regex.Replace(ArticleText, @"(?i)(?:(\d+),|)(\d+)\.(\d)(\d)[ ]?(?:lacs?\b|lakhs?\b|\[\[lakh(?:\|l|\|lac|)\]\]s?)", "$1$2$3$4,000");
ArticleText=Regex.Replace(ArticleText, @"(?i)(?:(\d+),|)(\d+)0,000[ ]?(?:lacs?\b|lakhs?\b|\[\[lakh(?:\|l|\|lac|)\]\]s?)", "$1$2 billion");
ArticleText=Regex.Replace(ArticleText, @"(?i)(?:(\d+),|)(\d+)0[ ]?(?:lacs?\b|lakhs?\b|\[\[lakh(?:\|l|\|lac|)\]\]s?)", "$1$2 million");
ArticleText=Regex.Replace(ArticleText, @"(?i)(?:(\d+),|)(\d+)(\d)[ ]?(?:lacs?\b|lakhs?\b|\[\[lakh(?:\|l|\|lac|)\]\]s?)", "$1$2.$3 million");
ArticleText=Regex.Replace(ArticleText, @"(?i)(?:(\d+),|)(\d+)[ ]?(?:lacs?\b|lakhs?\b|\[\[lakh(?:\|l|\|lac|)\]\]s?)", "$1${2}00,000");
ArticleText=Regex.Replace(ArticleText, @"(?i)(?:(\d+),|)(\d+)(\d)[ ]?(?:lacs?\b|lakhs?\b|\[\[lakh(?:\|l|\|lac|)\]\]s?)", "$1$2.$3 million");
ArticleText=Regex.Replace(ArticleText, @"(?i)(?:(\d+),|)(\d+)\.(\d)[0-4]?[ ]?(?:crores?|\[\[crore(?:\|cr|\|crores|)\]\]s?)", "$1$2$3 million");
ArticleText=Regex.Replace(ArticleText, @"(?i)(?:(\d+),|)(\d+)\.(\d)(\d+)[ ]?(?:crores?|\[\[crore(?:\|cr|\|crores|)\]\]s?)", "$1$2$3.$4 million");
ArticleText=Regex.Replace(ArticleText, @"(?i)(?:(\d+),|)(\d+)0[0-4][ ]?(?:crores?|\[\[crore(?:\|cr|\|crores|)\]\]s?)", "$1$2 billion");
ArticleText=Regex.Replace(ArticleText, @"(?i)(?:(\d+),|)(\d+)(\d\d)[ ]?(?:crores?|\[\[crore(?:\|cr|\|crores|)\]\]s?)", "$1$2.$3 billion");
ArticleText=Regex.Replace(ArticleText, @"(?i)(?:(\d+),|)(\d+)[ ]?(?:crores?|\[\[crore(?:\|cr|\|crores|)\]\]s?)", "$1${2}0 million");
ArticleText=Regex.Replace(ArticleText, @"(?i)\b(one)[ ](?:lacs?\b|lakhs?|\[\[lakhs?(?:\|l|\|lac|)\]\])", "$1 hundred thousand");
ArticleText=Regex.Replace(ArticleText, @"(?i)(?:one)[ ]?(?:crores?|\[\[crore(?:\|cr|\|crores|)\]\]s?)", "ten million");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\d+,|)(\d{3,})\.[0-4]\d?( [bm]illion)", "$1$2$3");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\d+,|)(\d{2,})1\.[5-9]\d?( [bm]illion)", "$1${2}2$3");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\d+,|)(\d{2,})2\.[5-9]\d?( [bm]illion)", "$1${2}3$3");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\d+,|)(\d{2,})3\.[5-9]\d?( [bm]illion)", "$1${2}4$3");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\d+,|)(\d{2,})4\.[5-9]\d?( [bm]illion)", "$1${2}5$3");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\d+,|)(\d{2,})5\.[5-9]\d?( [bm]illion)", "$1${2}6$3");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\d+,|)(\d{2,})6\.[5-9]\d?( [bm]illion)", "$1${2}7$3");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\d+,|)(\d{2,})7\.[5-9]\d?( [bm]illion)", "$1${2}8$3");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\d+,|)(\d{2,})8\.[5-9]\d?( [bm]illion)", "$1${2}9$3");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\d+,|)(\d+)\.0[0-4]?( [bm]illion)", "$1$2$3");
// Indian commas
ArticleText=Regex.Replace(ArticleText, @"(?i)(\W)(\d{1,3}),(\d\d),(\d\d),(\d\d),(\d\d),(\d\d\d)(?=[ \.,])", "$1{{formatnum:$2$3$4$5$6$7}}");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\W)(\d{1,3}),(\d\d),(\d\d),(\d\d),(\d\d\d)(?=[ \.,])", "$1{{formatnum:$2$3$4$5$6}}");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\W)(\d{1,3}),(\d\d),(\d\d),(\d\d\d)(?=[ \.,])", "$1{{formatnum:$2$3$4$5}}");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\W)(\d\d?),(\d\d),(\d\d\d)(?=[ \.,]|\/-)", "$1{{formatnum:$2$3$4}}");
ArticleText=Regex.Replace(ArticleText, @"(?i)([$£₤¥€]) (\d)", "$1$2");
ArticleText=Regex.Replace(ArticleText, @"(\{\{(?:INR|Indian Rupee)\}\}|Rs\.?) (\d+)", "$1$2");
// removing references to other WP articles and 'external' WP links
ArticleText=Regex.Replace(ArticleText, @"(?i)<ref>https?:\/\/\w{2}\.wik(?:ipedia|tionary)\.org\/wiki\/[^\s\]<]*<\/ref>", "");
ArticleText=Regex.Replace(ArticleText, @"(?i)<ref>\[https?:\/\/\w{2}\.wik(?:ipedia|tionary)\.org\/wiki\/[^\s\]]*[ ]+[\w\d][^\]]*\]<\/ref>", "");
ArticleText=Regex.Replace(ArticleText, @"(?i)[ ]\[https?:\/\/en\.wikipedia\.org\/wiki\/[^\s\]]*[ ]+([\w][^\]]*)\]", " [[$1]]");
//unprotect certain dates
ArticleText=Regex.Replace(ArticleText, @"(?i)(.)♫(.)", "$1$2");
//de-tagging for 'Use dmy dates|date='
ArticleText=Regex.Replace(ArticleText, @"(?i)\{\{(use (dmy|mdy) dates|dmy|mdy)(\|[^}]*)?\}\}\n?", "");
ArticleText=Regex.Replace(ArticleText, @"(?i)\{\{(use (British( \(Oxford\)|)|Indian|Irish) English|EngvarB)(\|[^}]*)?\}\}\n?", "");
ArticleText=Regex.Replace(ArticleText, @"(?i)\{\{reflist\|\d\}\}", "{{reflist|30em}}");
///General formatting
//adding piping to parentheticals
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[([^\[\]\(\)\|:]*)[ _](\([^\[\]\(\)\|]*(?:album|band|born \d{4}|film|magazine|newspaper|song)\))(\]\])", "[[$1 $2|$1$3"); //adding piping to parentheticals
//add correct hyphenation
ArticleText=Regex.Replace(ArticleText, @"\b([2-9]|\d{2,3}|half|quarter|two|three|four|five|six|seven|eight|nine|ten) (minute|hour|day|week|month|year|litre|litre|degree|inch|foot|yard|mile|metre|metre|man|page|point|word|dollar|cent|floor|store?y|room)\b", "$1-$2");
ArticleText=Regex.Replace(ArticleText, @"(?i)\b(two|three|four|five|six|seven|eight|nine|ten) (halves|thirds|quarters|(?:four|fif|six|seven|eigh|nin|ten)ths)\b", "$1-$2");
ArticleText=Regex.Replace(ArticleText, @"(?i)\b((?:[2-9]|\d{2,3})-(?:month|year)) (old)\b", "$1-$2");
ArticleText=Regex.Replace(ArticleText, @"(\bnon) ([A-Z]?[a-z]+)", "$1-$2");
//improper capitalisation within section headings
ArticleText=Regex.Replace(ArticleText, @"(==[ ]*External )(Links)(?=[ ]*=)", "$1links");
ArticleText=Regex.Replace(ArticleText, @"(==[ ]*See )(Also)(?=[ ]*=)", "$1also");
ArticleText=Regex.Replace(ArticleText, @"(==[ ]*)Notable ([A-Z]\w*?)", "$1$2");
ArticleText=Regex.Replace(ArticleText, @"(==[ ]*Box )O(ffice)(?=[ ]*=)", "$1o$2");
ArticleText=Regex.Replace(ArticleText, @"(==[ ]*[\w]+? and )A(wards?|chievements?)(?=[ ]*=)", "$1a$2");
ArticleText=Regex.Replace(ArticleText, @"(==[ ]*[\w\s]+? )A(lbums?)(?=[ ]*=)", "$1a$2");
ArticleText=Regex.Replace(ArticleText, @"(==[ ]*[\w\s]+? )C(areer|hampionships|haracters|ompositions)(?=[ ]*=)", "$1c$2");
ArticleText=Regex.Replace(ArticleText, @"(==[ ]*[\w\s]+? )E(ducation)(?=[ ]*=)", "$1e$2");
// ArticleText=Regex.Replace(ArticleText, @"(==[ ]*[\w\s]+? )G(roup)(?=[ ]*=)", "$1g$2");
ArticleText=Regex.Replace(ArticleText, @"(==[ ]*[\w\s]+? )H(istory|onou?rs)(?=[ ]*=)", "$1h$2");
ArticleText=Regex.Replace(ArticleText, @"(==[ ]*[\w\s]+? )L(evel|ife|isting)(?=[ ]*=)", "$1l$2");
ArticleText=Regex.Replace(ArticleText, @"(==[ ]*(?:1st|2nd|3rd|\dth) )M(atch)", "$1m$2");
ArticleText=Regex.Replace(ArticleText, @"(==[ ]*(?:1st|2nd|3rd|\dth) )F(inal)", "$1f$2");
ArticleText=Regex.Replace(ArticleText, @"(==[ ]*(?:First|Second|Third|Fourth|[1-4](?:st|nd|rd|th)) )P(lace)(?=[ ]*==)", "$1p$2");
ArticleText=Regex.Replace(ArticleText, @"(==[ ]*(?:First|Second|Third|Fourth|[1-4](?:st|nd|rd|th)) )Q(uarter)(?=[ ]*==)", "$1q$2");
ArticleText=Regex.Replace(ArticleText, @"(==[ ]*(?:First|Second|Third|Fourth|[1-4](?:st|nd|rd|th)) )R(ound)(?=[ ]*==)", "$1r$2");
ArticleText=Regex.Replace(ArticleText, @"(==[ ]*(?:CFL|N[BFH]L) )C(oaching )[Rr](ecords?)(?=[ ]*=)", "$1c$2r$3");
ArticleText=Regex.Replace(ArticleText, @"(==[ ]*[\w\s]+? )R(ankings?|eading|esults?|ecords?|eception|ecognition)(?=[ ]*=)", "$1r$2");
ArticleText=Regex.Replace(ArticleText, @"(==[ ]*[-\w\s]+? )C(areer )S(tatistics)(?=[ ]*=)", "$1c$2s$3");
ArticleText=Regex.Replace(ArticleText, @"(==[ ]*[\w\s]+? )S(eason|quad|tyle|tage|tatistics)(?=[ ]*=)", "$1s$2");
ArticleText=Regex.Replace(ArticleText, @"(==[ ]*[\w\s]+? )P(ersonnel)(?=[ ]*=)", "$1p$2");
ArticleText=Regex.Replace(ArticleText, @"(==[ ]*[\w\s]+? )R(esponses?)(?=[ ]*=)", "$1p$2");
ArticleText=Regex.Replace(ArticleText, @"(==[ ]*[\w\s]+? )T(ournaments?)(?=[ ]*=)", "$1t$2");
ArticleText=Regex.Replace(ArticleText, @"(==[ ]*[\w\s]+? )Y(ears)(?=[ ]*=)", "$1y$2");
ArticleText=Regex.Replace(ArticleText, @"(==[ ]*Exhibition )S(chedule)(?=[ ]*=)", "$1s$2");
ArticleText=Regex.Replace(ArticleText, @"(==[ ]*Regular )Season Schedule(?=[ ]*=)", "$1season schedule");
ArticleText=Regex.Replace(ArticleText, @"(==[ ]*Right )[Oo]f Reply(?=[ ]*=)", "$1of reply");
ArticleText=Regex.Replace(ArticleText, @"(==[ ]*Terminated )D(estinations)(?=[ ]*=)", "$1d$2");
ArticleText=Regex.Replace(ArticleText, @"(==[ ]*Twin )T(owns)(?=[ ]*=)", "$1t$2");
ArticleText=Regex.Replace(ArticleText, @"(==[ ]*Twin )(Towns [Aa]nd [Ss]ister [Cc]ities)(?=[ ]*=)", "$1towns and sister cities");
ArticleText=Regex.Replace(ArticleText, @"(==[ ]*Heraldic )(Items)(?=[ ]*=)", "$1items");
ArticleText=Regex.Replace(ArticleText, @"(==[ ]*Campaign )C(redits)(?=[ ]*=)", "$1c$2");
ArticleText=Regex.Replace(ArticleText, @"(==[ ]*Combat )C(hronicle)(?=[ ]*=)", "$1c$2");
//other improper capitalisation
ArticleText=Regex.Replace(ArticleText, @"([ ]*(?:\d\d?\W |)(?:CD |Cassette ))S(ingles?)\b", "$1s$2");
ArticleText=Regex.Replace(ArticleText, @"([ ]*(?:\d\d?\W |CD |Cassette ))S(ingles?)\b", "$1s$2");
// ArticleText=Regex.Replace(ArticleText, @"(\d(?:st|nd|rd|th) )C(entur(?:ies|y))(?=[ ]*(=|BC|AD|CE))", "$1c$2"); //transferring to MOSNUM script
// ArticleText=Regex.Replace(ArticleText, @"(\d(?:st|nd|rd|th) )C(entur(?:ies|y))(?![ -]*(?:Fox|[A-Z]\w*))", "$1c$2");
ArticleText=Regex.Replace(ArticleText, @"\b(Bowling |Batting )S(tyle)\b", "$1s$2");
ArticleText=Regex.Replace(ArticleText, @"\b(lef|righ)t-Handed Opening B(atsman)\b", "$1t-handed opening b$2");
ArticleText=Regex.Replace(ArticleText, @"\b(lef|righ)t-Handed Top Order B(atsman)\b", "$1t-handed top-order b$2");
ArticleText=Regex.Replace(ArticleText, @"\b([Aa]ll)[- ]R(ounder)\b", "$1-r$2");
ArticleText=Regex.Replace(ArticleText, @"\b(Wicket)[- ]K(eeper)\b", "$1-k$2");
ArticleText=Regex.Replace(ArticleText, @"\b(fast)[-– ](medium )B(owler)\b", "$1–$2b$3");
ArticleText=Regex.Replace(ArticleText, @"\b([Ff]ast |[Mm]edium )B(owler)\b", "$1b$2");
ArticleText=Regex.Replace(ArticleText, @"\b([Ff]ast|[Ss]low)[-– ](lef|righ)t-[Aa]rm B(owler)\b", "$1 $2-arm b$3");
ArticleText=Regex.Replace(ArticleText, @"\b(fast)[- ]B(owler)\b", "$1-b$2");
ArticleText=Regex.Replace(ArticleText, @"\b([Ll]eg|[Oo]ff)[- ][Ss](pin )B(owler)\b", "$1-s$2b$3");
ArticleText=Regex.Replace(ArticleText, @"\b(st|nd|rd|th) G(rade)\b", "$1 g$2");
// ArticleText=Regex.Replace(ArticleText, @"(Official )S(ite)", "$1s$2");
// ArticleText=Regex.Replace(ArticleText, @"([A-Z][a-z]+ )O(fficial )W(ebsite\])", "$1o$2w$3");
ArticleText=Regex.Replace(ArticleText, @"(\'Further )R(eading)(?=\')", "$1r$2");
ArticleText=Regex.Replace(ArticleText, @"(\w )A(nd|t) A(n? \w)", "$1a$2 a$3");
ArticleText=Regex.Replace(ArticleText, @"(\w )A(nd|t) (My \w)", "$1a$2 $3");
ArticleText=Regex.Replace(ArticleText, @"(\w )A(nd|t) T(he \w)", "$1a$2 t$3");
ArticleText=Regex.Replace(ArticleText, @"(\w )By A(n? \w)", "$1by a$2");
ArticleText=Regex.Replace(ArticleText, @"(\w )By (My \w)", "$1by $2");
ArticleText=Regex.Replace(ArticleText, @"(\w )By T(he \w)", "$1by t$2");
ArticleText=Regex.Replace(ArticleText, @"(\w )For A(n? \w)", "$1for a$2");
ArticleText=Regex.Replace(ArticleText, @"(\w )For (My \w)", "$1for $2");
ArticleText=Regex.Replace(ArticleText, @"(\w )For T(he \w)", "$1for t$2");
ArticleText=Regex.Replace(ArticleText, @"(\w )In A(n? \w)", "$1in a$2");
ArticleText=Regex.Replace(ArticleText, @"(\w )In (My \w)", "$1in $2");
ArticleText=Regex.Replace(ArticleText, @"(\w )In T((?:he|o) \w)", "$1in t$2");
ArticleText=Regex.Replace(ArticleText, @"(\w )I(nto \w)", "$1i$2");
ArticleText=Regex.Replace(ArticleText, @"(\w )O(f|n|r) A(n? \w)", "$1o$2 a$3");
ArticleText=Regex.Replace(ArticleText, @"(\w )O(f|n|r) (My \w)", "$1o$2 $3");
ArticleText=Regex.Replace(ArticleText, @"(\w )O(f|n|r) T(he \w)", "$1o$2 t$3");
ArticleText=Regex.Replace(ArticleText, @"(\w )To A(n? \w)", "$1to a$2");
ArticleText=Regex.Replace(ArticleText, @"(\w )To (My \w)", "$1to $2");
ArticleText=Regex.Replace(ArticleText, @"(\w )To T(he \w)", "$1to t$2");
ArticleText=Regex.Replace(ArticleText, @"(\w )With A(n? \w)", "$1with a$2");
ArticleText=Regex.Replace(ArticleText, @"(\w )With M(y \w)", "$1with M$2");
ArticleText=Regex.Replace(ArticleText, @"(\w )With T(he \w)", "$1with t$2");
ArticleText=Regex.Replace(ArticleText, @"(\w )A(t \w)", "$1a$2");
ArticleText=Regex.Replace(ArticleText, @"(\w )I(n \w)", "$1i$2");
ArticleText=Regex.Replace(ArticleText, @"(\w )O([fn] \w)", "$1o$2"); //'Or' - false positive (with heraldric Or); 'On' - name (e.g. Ma On Shan)
ArticleText=Regex.Replace(ArticleText, @"([Rr]unners?)[\- ]U(p\b)", "$1-u$2");
ArticleText=Regex.Replace(ArticleText, @"([Rr]unner)[\- ][Uu](?:ps)\b", "$1s-up");
ArticleText=Regex.Replace(ArticleText, @"([Pp]lay)[\- ][Oo](ffs?)", "$1-o$2");
ArticleText=Regex.Replace(ArticleText, @"(\W[^A-Z]+ )[Qq](uarter)[\- ]F(inal)", "$1q$2-f$3");
ArticleText=Regex.Replace(ArticleText, @"([Qq]uarter)[\- ]F(inal)", "$1-f$2");
ArticleText=Regex.Replace(ArticleText, @"(\W[^A-Z]+ )[Ss](emi)[\- ]F(inal)", "$1s$2-f$3");
ArticleText=Regex.Replace(ArticleText, @"([Ss]emi)[\- ]F(inal)", "$1-f$2");
ArticleText=Regex.Replace(ArticleText, @"(Bring |Turn )[Ii]t o(n)", "$1It O$2"); //reverting proper name - title of song or work
ArticleText=Regex.Replace(ArticleText, @"(Carry )o(n [A-Z]\w*|n film)", "$1O$2"); //reverting proper name - 'Carry On' film series
ArticleText=Regex.Replace(ArticleText, @"(Ma )o(n Shan)", "$1O$2"); //reverting proper name - 'Ma On Shan'
ArticleText=Regex.Replace(ArticleText, @"(NZ |New Zealand )o(n Air|n Screen)", "$1O$2"); //reverting proper name - 'NZ On Air'
ArticleText=Regex.Replace(ArticleText, @"in t(he [Aa]ir [Tt]onight)", "In t$1"); //reverting per "In the Air Tonight"
ArticleText=Regex.Replace(ArticleText, @"in t(he Flesh [Tt]our)", "In t$1"); //reverting per "In the Flesh tour"
ArticleText=Regex.Replace(ArticleText, @"(\W)o(n This Day)", "$1O$2"); //reverting per "on This Day"
ArticleText=Regex.Replace(ArticleText, @"(Star Trek )into( Darkness)", "$1Into$2"); //reverting proper name - title of work
//remove flagicons from country, birth and death etc
ArticleText=Regex.Replace(ArticleText, @"(?i)((?:birth|death|place|chairman|coach|manager|nationality)\s*=)\s*\{\{flag ?icon\|[^{}]+\}\}", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)(<br ?\/?>)\s*\{\{flag ?icon\|[^{}|]+\}\}", "$1");
//remove scroll bar for reflists
ArticleText=Regex.Replace(ArticleText, @"(?i)(References ?={1,4}[\n\r][\r\n\s]*)<div class=[^>]*>([\S\s]*?)<\/div>", "$1$2");
ArticleText=Regex.Replace(ArticleText, @"(?i)((?:Notes ?|References ?)={2,4}\s?[\n\r][\r\n\s]*)(?:\{\{[Rr]eflist\|[2,3]\}\})", "$1{{reflist|colwidth=30em}}");
//rem redundant spaces underlining and punctuation
ArticleText=Regex.Replace(ArticleText, @"(?i)(\W)[“](\[?\w+)", "$1\"$2");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\w+\]?)(,|\.|)[”](\W)", "$1\"$2$3"); //quotemark plus incidental LQ
ArticleText=Regex.Replace(ArticleText, @"(?i)(\W)[‘`´’′](\[?\w+)", "$1\'$2");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\w+\]?\.?)[‘`´’′](\W)", "$1\'$2"); // replace various single quotes and prime symbol with straight apostrophe
ArticleText=Regex.Replace(ArticleText, @"(?i)([\w;,\]\)>] ) +([\[\w(])", "$1$2"); //rem multiple spaces except when preceded by full stop
ArticleText=Regex.Replace(ArticleText, @"(?i)(^\.U\.)[ ]+((?:S|K)\.)", "$1$2"); //U. S. and U. K. to U.S. and U.K.
ArticleText=Regex.Replace(ArticleText, @"(?i)(<\/?ref(?: name=[^\<\>\/]*?|)>)[ ,\. ]*(<ref)", "$1$2"); // remove punctuation between ref tags
ArticleText=Regex.Replace(ArticleText, @"(?i)[ ]{1,3}(<\/?ref(?:>| >| n))", "$1"); // remove spaces preceding ref tags and templates
// ArticleText=Regex.Replace(ArticleText, @"(?i)[ ]+(\n|\r)", "$1"); //removes multiple spaces preceding line break [disabled on 2 Dec 2013 as pointless]
ArticleText=Regex.Replace(ArticleText, @"(?i)(\d), ([12]\d{3}\b)+", "$1, $2"); //removes nbsp preceding year
ArticleText=Regex.Replace(ArticleText, @"(?i)(\d)(?: | )%", "$1%"); //removes nbsp preceding '%'
ArticleText=Regex.Replace(ArticleText, @"(?i)( )[ ](–|–)", "$1$2"); //Palliative for dashes script insertion of space after nbsp
ArticleText=Regex.Replace(ArticleText, @"\b(US|UK|A(?:US|)|C(?:AN|)|NZ|HK) ([$£¥€])(\d)", "$1$2$3");
ArticleText=Regex.Replace(ArticleText, @"\{\{AUD\}\} ?(\d+)", "A$ $1");
ArticleText=Regex.Replace(ArticleText, @"([$£¥€]) (\d)", "$1$2");
ArticleText=Regex.Replace(ArticleText, @"(\{\{(?:INR|Indian Rupee)\}\}|Rs\.?)(\d+)", "$1 $2");
//rem bolding from linked AND bolded terms
// ArticleText=Regex.Replace(ArticleText, @"'''(\[\[)([^\|\]]+?\||)([^\]]+?\]\][:-–]?)'''", "$1$2$3");
//rem 'external' wiktionary links
ArticleText=Regex.Replace(ArticleText, @"(?i)\[https?:\/\/en\.wiktionary\.org\/wiki\/[\w]*[ ](\w[^\]]*)\]", "$1");
//rem linked copyright symbol
ArticleText=Regex.Replace(ArticleText, @"(?i)(\[\[copyright\|©\]\] |©)", "");
//rem leading and lagging spaces within wikilinks
ArticleText=Regex.Replace(ArticleText, @"(?i)(\[\[)[ ]+([^\[\]\|]*?)[ ]*(\]\])", "$1$2$3");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\[\[)[ ]*([^\[\]\|]*?)[ ]+(\]\])", "$1$2$3");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\[\[[^\[\]\|]*?[ ])[ ]+([^\[\]]*?\]\])", "$1$2");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\[\[[^\[\]\|]*?)[ ]+\|[ ]*([^\[\]]+\]\])", "$1|$2");
// ArticleText=Regex.Replace(ArticleText, @"(?i)(\[\[[^\[\]\|]*?)[ ]*\|[ ]+([^\[\]]+\]\])", "$1|$2"); //can't remember why we need the second (repeated) line
//symbol for 'times' and dashes
// ArticleText=Regex.Replace(ArticleText, @"(?i)×", "×");
// ArticleText=Regex.Replace(ArticleText, @"(?i)([ \.][\d]+)x([\d]+(?:\.[\d]+|)\s)", "$1 × $2"); //disabling - never ending false positives
ArticleText=Regex.Replace(ArticleText, @"(?i)(\d) x (\d )", "$1 × $2");
ArticleText=Regex.Replace(ArticleText, @"\s(A[cglmrstu]|B[ahikrad]?|C[adeflmno]|D[bsyrsu]|E[rsu]|F[elmr]?|G[adef]|H[fgos]|I[nr]?|Kr?|L[aruv]|M[dgnot]|N[abdeiop]?|Os?|P[abdmortu]?|R[abefghnu]|S[bcegimnr]?|T[abcehilm]?|U[ub][neopst]|V|W|Xe|Yb?|Z[nr])-(Br|Cl?|F|H|I|N|O|P|Se?)\s", " $1–$2 "); //signifying chemical bonds abbrev
// ArticleText=Regex.Replace(ArticleText, @"(?i)([^<][^!] *)--( *[^>])", "$1–$2"); //disabling - causes false positives with urls and some images
ArticleText=Regex.Replace(ArticleText, @"(?i)—", "—");
ArticleText=Regex.Replace(ArticleText, @"(?i)([\w\d]) — (?=[\w\d])", "$1 – "); // tweak to avoid replacing emdashes in strings that are in non-roman unicode characters
ArticleText=Regex.Replace(ArticleText, @"(?i)(\D7\d7)–(\d(?:00|)\D)", "$1-$2"); //airplane model numbers taking hyphen
//inserting a white space between wikilinks to avoid errors upon unlinking
ArticleText=Regex.Replace(ArticleText, @"(?i)(\]\][\.,]?)(\[\[)(?!file|image)", "$1 $2");
//hash fixes
ArticleText=Regex.Replace(ArticleText, @"(?i)([^=] )#(\d{1,3}[,\.]?\s)", "$1No. $2");
//full stop and nbsp fixes
//degrees
ArticleText=Regex.Replace(ArticleText, @"(Ph)(?:\.\s?|\s)(D)\.?", "$1$2");
ArticleText=Regex.Replace(ArticleText, @"(B|M)(?:\.\s?|\s)(Arch|Comm|Ed|Eng|Sc|Tech)\.?(?=\W)", "$1$2");
//times of day, time ranges
// ArticleText=Regex.Replace(ArticleText, @"(?i)((?:\d?\d[:\.]\d?\d| \d?\d) [ap])(?:\.m\.)(?=[^\w\-])", "$1m");
// ArticleText=Regex.Replace(ArticleText, @"(?i)(\d?\d[:\.]\d?\d| \d?\d)(?:[ ]*| )(?:a\.m\.|am)(?:[ ]*| )[-–—](?:[ ]*| )(\d?\d[:\.]\d?\d|\d?\d)(?:[ ]*| )(?:p\.m\.|pm)(?=[^\w\-])", "$1 am – $2 pm");
// ArticleText=Regex.Replace(ArticleText, @"(?i)(\d?\d[:\.]\d?\d| \d?\d)(?:[ ]*| )(?:p\.m\.|pm)(?:[ ]*| )[-–—](?:[ ]*| )(\d?\d[:\.]\d?\d|\d?\d)(?:[ ]*| )(?:a\.m\.|am)(?=[^\w\-])", "$1 pm – $2 am");
// ArticleText=Regex.Replace(ArticleText, @"(?i)(\d?\d[:\.]\d?\d| \d?\d)(?:[ ]*| )(?:a\.m\.|am)(?:[ ]*| )[-–—](?:[ ]*| )(\d?\d[:\.]\d?\d|\d?\d)(?:[ ]*| )(?:a\.m\.|am)(?=[^\w\-])", "$1 am – $2 am");
// ArticleText=Regex.Replace(ArticleText, @"(?i)(\d?\d[:\.]\d?\d| \d?\d)(?:[ ]*| )(?:p\.m\.|pm)(?:[ ]*| )[-–—](?:[ ]*| )(\d?\d[:\.]\d?\d|\d?\d)(?:[ ]*| )(?:p\.m\.|pm)(?=[^\w\-])", "$1 pm – $2 pm");
// ArticleText=Regex.Replace(ArticleText, @"(?i)(\d?\d[:\.]\d?\d| \d?\d)(?:[ ]*| )(?:a\.m\.|am)(?:[ ]*| )[-–—](?:[ ]*| )(noon|midnight)(?=[^\w\-])", "$1 am – $2");
// ArticleText=Regex.Replace(ArticleText, @"(?i)(\d?\d[:\.]\d?\d| \d?\d)(?:[ ]*| )(?:p\.m\.|pm)(?:[ ]*| )[-–—](?:[ ]*| )(noon|midnight)(?=[^\w\-])", "$1 pm – $2");
// ArticleText=Regex.Replace(ArticleText, @"(?i)\b(\d?\d[:\.]\d?\d| \d?\d)(?:[ ]*| )(?:a\.m\.|am)(?=[^\w\-])", "$1 am");
// ArticleText=Regex.Replace(ArticleText, @"(?i)\b(\d?\d[:\.]\d?\d| \d?\d)(?:[ ]*| )(?:p\.m\.|pm)(?=[^\w\-])", "$1 pm");
ArticleText=Regex.Replace(ArticleText, @"(\d\.\d?\d| \d{1,3}| \d{1,3},\d{3})[ ]*(?:kw)\b", "$1 kW");
ArticleText=Regex.Replace(ArticleText, @"(\d\.\d?\d| \d{1,3}| \d{1,3},\d{3})[ ]*(?:khz)\b", "$1 kHz");
ArticleText=Regex.Replace(ArticleText, @"(\d\.\d?\d| \d{1,3}| \d{1,3},\d{3})[ ]*(?:m[Hh]z)\b", "$1 MHz");
ArticleText=Regex.Replace(ArticleText, @"(\d\.\d?\d| \d{1,3}| \d{1,3},\d{3})[ ]*(?:g[Hh]z)\b", "$1 GHz");
ArticleText=Regex.Replace(ArticleText, @"(\d\.\d?\d| \d{1,3}| \d{1,3},\d{3})[ ]*(?:kph|kphr|kmh|kmhr|kmph|kmphr|km\/hr)\b", "$1 km/h");
ArticleText=Regex.Replace(ArticleText, @"(\d\.\d?\d| \d{1,3}| \d{1,3},\d{3})[ ]*(?:m\.p\.h\.)\b", "$1 mph");
ArticleText=Regex.Replace(ArticleText, @"(\d\.\d?\d| \d{1,3}| \d{1,3},\d{3})[ ]*(gm|kg|km)s?\b", "$1 $2");
ArticleText=Regex.Replace(ArticleText, @"(\d\.\d?\d| \d{1,3}| \d{1,3},\d{3})[ ]*KMs?\b", "$1 km");
ArticleText=Regex.Replace(ArticleText, @"(\d\.\d?\d| \d{1,3}| \d{1,3},\d{3})[ ]*KGs?\b", "$1 kg");
ArticleText=Regex.Replace(ArticleText, @"(\d\.\d?\d| \d{1,3}| \d{1,3},\d{3})[ ]*(?:K(g|m))s?\b", "$1 k$2");
ArticleText=Regex.Replace(ArticleText, @"(\d\.\d?\d| \d{1,3}| \d{1,3},\d{3})[ ]*cms?", "$1 cm");
// ArticleText=Regex.Replace(ArticleText, @"([^\|\[=]\d{1,3})\s(m|b|tr)illion(\b[^}])", "$1 $2illion$3");
//turn letter 'x' into symbol '×'
ArticleText=Regex.Replace(ArticleText, @"(?i)(\d)\sx\s(\d{1,3})\sin\s\(", "$1 × $2 in (");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\d)\sx\s(\d{1,3})\sinch\s", "$1 × $2 inch ");
// Convert degree symbols into ° symbol, ensure preceding space
ArticleText=Regex.Replace(ArticleText, @"°", "°");
// ArticleText=Regex.Replace(ArticleText, @"º", "°");
// Celsius spelling errors
ArticleText=Regex.Replace(ArticleText, @"(?i)(?:celsius|celcius|centigrade)", "Celsius");
//Fix common naming error (be careful with this one)
// ArticleText=Regex.Replace(ArticleText, @"(?i)centigrade", "Celsius");
//Celsius or Fahrenheit
ArticleText=Regex.Replace(ArticleText, @"(\d) (?:[°º]|deg|degree|degrees) ([CF]\W)", "$1 °$2");
ArticleText=Regex.Replace(ArticleText, @"(\d)(?:[°º]|deg|degree|degrees) ([CF]\W)", "$1 °$2");
ArticleText=Regex.Replace(ArticleText, @"(\d) (?:[°º]|deg|degree|degrees)([CF]\W)", "$1 °$2");
ArticleText=Regex.Replace(ArticleText, @"(\d)(?:\s|)(?:[°º]|deg|degree|degrees)(?:\s|)([CF]\W)", "$1 °$2");
ArticleText=Regex.Replace(ArticleText, @"(\d)(?:\s| )?(?=\[\[Celsius\|[°º]C\]\])", "$1 $2");
ArticleText=Regex.Replace(ArticleText, @"(\d)(?:\s| )?(?=\[\[Fahrenheit\|[°º]F\]\])", "$1 $2");
ArticleText=Regex.Replace(ArticleText, @"([^\d\(\)\/\\]\s)(-?\d[\d,\.]*)(?:\s|-| |)[°º]F([:;,\.?!]?\s[^\d\(\)\/\\])", "$1{{convert|$2|°F|°C|abbr=on}}$3");
ArticleText=Regex.Replace(ArticleText, @"([^\d\(\)\/\\]\s)(-?\d[\d,\.]*)(?:\s|-| |)(?:deg|degree|degrees)(?:\s|-| |)Fahrenheit([:;,\.?!]?\s[^\d\(\)\/\\])", "$1{{convert|$2|°F|°C}}$3");
// Convert &sup to superscript
// ArticleText=Regex.Replace(ArticleText, @"(?i)(m)(?:²|²);", "$1<sup>2</sup>");
// ArticleText=Regex.Replace(ArticleText, @"(?i)(m)(?:³|³);", "$1<sup>3</sup>");
//remove commas from numerical values in convert template
ArticleText=Regex.Replace(ArticleText, @"(?i)(\{convert\|\d+),(\d)", "$1$2");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\{convert\|\d+),(\d)", "$1$2");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\{convert\|\d+),(\d)", "$1$2");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\{convert\|\d+),(\d)", "$1$2");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\{convert\|\d+),(\d)", "$1$2");
//remove leading zeros from convert template
ArticleText=Regex.Replace(ArticleText, @"(?i)(\{\{convert\s*\|)\s*0+(?=[1-9])", "$1$2");
///per WP:COMMONALITY
ArticleText=Regex.Replace(ArticleText, @"(?i)([Ff])reshman (year)", "$1irst $2");
ArticleText=Regex.Replace(ArticleText, @"(?i)([Ss])ophomore (album|year)", "$1econd $2");
//Currency notation placements [$£₤¥€]
ArticleText=Regex.Replace(ArticleText, @"(?i)\s(\$(?:\d+\.\d\d?|\d{1,3}|\d{1,3},\d{3}))((?:\s| )(?:m|b|tr)illion|)[ ]*(?:US(?:[D$]|\s?dollars?))\b", " US$1$2");
//Remove surprise or 'Easter egg' diversions linking unit name to orders of magnitude articles
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[1\s?_?E\s?[\-\+]?\d{1,2}\s?..?\|([^\]]{1,50})\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[Orders\sof\smagnitude\s\([^\)]+\)\|([^\]]{1,50})\]\]", "$1");
//remove useless comments
ArticleText=Regex.Replace(ArticleText, @"<!-- Metadata: see \[\[Wikipedia:Persondata\]\]\. -->", "");
ArticleText=Regex.Replace(ArticleText, @"<!-- Deleted image removed:[^>]*? -->\n*", "");
ArticleText=Regex.Replace(ArticleText, @"<!--DASHBot-->(?=\|)", "");
///dashes
ArticleText=Regex.Replace(ArticleText, @"(?i)(\|(?:1[89]|20)\d{2})-(\d{2}\]\])", "$1–$2");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\[\[1[89]\d{2})-(\d{2}\D)", "$1–$2");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\[\[20[01]\d)-([012]\d\D)", "$1–$2");
///LINK RATIONALISATION
// Country and language; city
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(area|cit(?:y center|y centre|ies|y)|countr(?:y|ies)|count(?:y|ies)|district|parish|province|region|rural|suburb|town(?:ship|)|urban(?: area|)|village)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(?:(?:rural|(?:sub)?urban)(?: area|i[sz]ation|)\||)((?:rural|(?:sub?)urban)(i[sz]ed?|i[sz]ation|))\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(?:List of (?:countries|U.S. states|sovereign states)|Countries of the world)\|(country|countries|states?)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[((?:US|U\.S\.) states?)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(?:US|U\.S\.) states?\|(states?)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[States and territories of India\|(state)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[city\|(cities)\]\]", "$1");
//Chained countries
ArticleText=Regex.Replace(ArticleText, @"(?i)(\]\], )\[\[(Abkhazia|Afghanistan|Albania|Algeria|Andorra|Angola|Antigua and Barbuda|Argentina|Armenia|Australia|Austria|Azerbaijan|(?:The |)Bahamas|Bahrain|Bangladesh|Barbados|Belarus|Belgium|Belize|Benin|Bhutan|Bolivia|Bosnia|Herzegovina|Botswana|Brazil|Brunei|Bulgaria|Burkina Faso|Burma|Burundi|Cambodia|Cameroon|Canada|Cape Verde|Central African Republic|Chad|Chile|(?:(?:People's |)Republic of |)China|Colombia|Comoros|(?:Democratic |)Republic of (?:the |)Congo|Costa Rica|Côte d'Ivoire|Croatia|Cuba|Cyprus|Czech Republic|(?:Kingdom of |)Denmark|Djibouti|Dominica|Dominican Republic|East Timor|Ecuador|Egypt|El Salvador|Equatorial Guinea|Eritrea|Estonia|Ethiopia|Fiji|Finland|France|Gabon|(?:East |West |)Germany|Ghana|Greece|Greenland|Grenada|Guatemala|Guinea|Guinea-Bissau|Guyana|Haiti|Honduras|Hungary|Iceland|India|Indonesia|Iran|Iraq|(?:Republic of |)Ireland|Israel|Italy|Jamaica|Japan|Jordan|Kazakhstan|Kenya|Kiribati|North Korea|South Korea|Kosovo|Kuwait|Kyrgyzstan|Laos|Latvia|Lebanon|Lesotho|Liberia|Libya|Liechtenstein|Lithuania|Luxembourg|(?:Republic of |)Macedonia|Madagascar|Malawi|Malaysia|Maldives|Mali|Malta|Marshall Islands|Mauritania|Mauritius|M[ée]xico|(?:Federated States of |)Micronesia|Moldova|Monaco|Mongolia|Montenegro|Morocco|Mozambique|Nagorno-Karabakh|Namibia|Nauru|Nepal|(?:(?:Kingdom of |)the |)Netherlands|Holland|New Zealand|Nicaragua|Niger|Nigeria|Northern Cyprus|Norway|Oman|Pakistan|Palau|Palestine|Panama|Papua New Guinea|Paraguay|Peru|Philippines|Poland|Portugal|Qatar|Romania|Russia|Rwanda|SADR|Saint Kitts and Nevis|Saint Lucia|Saint Vincent and the Grenadines|Samoa|San Marino|São Tomé and Príncipe|Saudi Arabia|Senegal|Serbia|Seychelles|Sierra Leone|Singapore|Slovakia|Slovenia|Solomon Islands|Somalia|Somaliland|South Africa|South Ossetia|Spain|Sri Lanka|Sudan|Suriname|Swaziland|Sweden|Switzerland|Syria|Taiwan|Tajikistan|Tanzania|Thailand|(?:The |)Gambia|Togo|Tonga|Transnistria|Trinidad and Tobago|Tunisia|Turkey|Turkmenistan|Tuvalu|Uganda|Ukraine|United Arab Emirates|United Kingdom|England|Scotland|Wales|Northern Ireland|United States|Uruguay|Uzbekistan|Vanuatu|Vatican City|Venezuela|Vietnam|Yemen|Zambia|Zimbabwe)\]\](?=[\.\)]|[ ]*[\n\r])", "$1$2");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(?:(?:People's Republic of |)China|England|France|Germany|Great\sBritain|Japan|South African|Spain|United\sKingdom|U\.K\.|UK|United\sStates(?:\sof\sAmerica|)|US|U\.S\.|USA|U\.S\.A\.)\|(British|Chinese|English|French|German|Japanese|Spanish|American|US)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(?:United\sStates(?:\sof\sAmerica|)\||)(USA?|U\.S\.(?:A\.|))\]\]", "US");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(?:United\sStates(?:\sof\sAmerica|)\||)(USA?|U\.S\.(?:A\.|)|United\sStates(?:\sof\sAmerica|))\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\]\], )\[\[Georgia \(country\)\|(Georgia)\]\](?=[\.\)]|[ ]*[\n\r])", "$1$2");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\]\], )\[\[Republic of Ireland\|(Ireland)\]\](?=[\.\)]|[ ]*[\n\r])", "$1$2");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[People's Republic of China\|(China)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(?:United\sKingdom(?:\sof\sGreat Britain and Northern Ireland|)\||)(U\.K\.|UK|United\sKingdom)\]\]", "UK");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\]\], )\[\[(England|Wales|Scotland|Northern Ireland)\]\],? (\[\[United Kingdom(?:\|UK|)\]\]|United Kingdom|UK)(?=\.|[ ]*[\n\r])", "$1$2");
//Nationalities egged to country
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(Abkhazia|Albania|Algeria|Andorra|Angola|Antigua and Barbuda|Armenia|Australia|Austria|Azerbaijan|Bahrain|Bangladesh|Belarus|Belize|Benin|Bhutan|Bolivia|Bosnia and Herzegovina|Botswana|Brazil|Brunei|Bulgaria|Burma|Burundi|Cambodia|Cameroon|Canada|Cape Verde|Chad|Chile|Colombia|Comoros|Congo|Costa Rica|Côte d'Ivoire|Croatia|Cuba|Cyprus|Djibouti|Dominica|Dominican Republic|East Timor|Ecuador|Egypt|El Salvador|Equatorial Guinea|Eritrea|Estonia|Ethiopia|Fiji|Gabon|Ghana|Greenland|Grenada|Guatemala|Guinea|Guinea-Bissau|Guyana|Haiti|Iceland|India|Indonesia|Iran|Iraq|Israel|Jamaica|Japan|Jordan|Kenya|Kiribati|North Korea|South Korea|Kosovo|Kuwait|Latvia|Lesotho|Liberia|Libya|Liechtenstein|Lithuania|Luxembourg|(?:Republic of |)Macedonia|Malawi|Malaysia|Maldives|Mali|Marshall Islands|Mauritania|(?:Federated States of |)Micronesia|Moldova|Mongolia|Nagorno-Karabakh|Namibia|Nauru|Nepal|New Zealand|Nicaragua|Niger|Nigeria|Northern Cyprus|Oman|Pakistan|Palau|Palestine?|Panama|Papua New Guinea|Paraguay|Peruv|Philippines?|Qatar|Romania|Russia|Rwanda|Sahrawi|Kittitian|Saint Lucia|Vincent|Samoa|San Marino?|São Tomé and Príncipe|Saudi Arabia|Senegal|Serbia|Seychelles|Sierra Leone|Singapore|Slovenia|Solomon Islands|Somalia|Somaliland|South Africa|South Ossetia|Spai?n|Sri Lanka|Sudan|Suriname|Swaziland|Swed|Syria|Taiwan|Tanzania|(?:The |)Gambia|Togo|Tonga|Transnistria|Trinidad|Tobag|Tunisia|Turk|Tuvalu|Uganda|Ukrain|United Arab Emirates|United States|Uruguay|Vanuatu|Vatican City|Venezuela|Vietnam|Yemen|Zambia|Zimbabwe)\]\](?=ese|(?:i?a|)n|ic?|ish)\b", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[Belgium\|(Belgian)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(?:Burma|Myamnar)\|(Burmese)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[Canada\|(Canadian)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(?:(?:People's |)Republic of |)China\|(Chinese)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(?:Czech|Slovak) Republic\|(Czech|Slovak(?:ian|))\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[Cyprus\|(Cypriot)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(?:Kingdom of |)Denmark\|(Danish)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[France\|(French)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[Finland\|(Finnish)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[Greece\|(Greek)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(?:East |West |)Germany\|((?:East |West |)German)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(?:(?:(?:Kingdom of |)the |)Netherlands|Holland)\|(Dutch)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[Honduras\|(Honduran)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[Hungary\|(Hungarian)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(?:Republic of |)Ireland\|(Irish)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[Italy\|(Italian)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[Laos\|(Laotian)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[Lebanon\|(Lebanese)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[Republic of Macedonia\|(Macedonian)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[Madagascar\|(Madagascan)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[Malta\|(Maltese)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[Monaco\|(Mon[eé]gasque)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[Mozambique\|(Mozambican)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(M[ée]xic|Montenegr|Morocc)o\|\1(an)\]\]", "$1$2");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[Mauritius\|(Mauritian)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[Norway\|(Norwegian)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[Poland\|(Polish)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[Portugal\|(Portuguese)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[Spain\|(Spanish)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[Switzerland\|(Swiss)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[Thailand\|(Thai)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[Turkey\|(Turk(?:ish|))\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(Afghan|Kazakh|Kyrgyz|Tajik|Turkmeni|Uzbek)i?stan\|\1\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(?:Great Britain|United Kingdom)\|(British|UK)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[England\|(English)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[Scotland\|(Scottish)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[Wales\|(Welsh)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[Northern Ireland\|(Northern Irish)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(?:USSR|Soviet Union|Union of Soviet Socialist Republics)\|(Soviet)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[United\sStates(?:\sof\sAmerica|)\|(USA?|U\.S\.(?:A\.|)|American)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(?:USD|United\sStates(?:\sdollar|$))\|(US[D$]|\$)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[([^\]]{1,26})\,\s(Cambridge|Oxford|London)\|([^\]]{1,26})\]\]\,?\s(Cambridge|Oxford|London)(\sUniversity|)", "[[$1, $2]]");
// [[Salt Lake City, Utah|Salt Lake City]], [[Utah]] -> [[Salt Lake City, Utah|Salt Lake City]], Utah
ArticleText=Regex.Replace(ArticleText, @"(?i)(\[\[([^|\[\]]*), ([^|\]]*)\|\2\]\],[ ])\[\[\3\]\]", "$1$3");
// [[Tacoma, Washington|Tacoma]], [[Washington (U.S. state)|Washington]] -> [[Tacoma, Washington|Tacoma]], Washington
ArticleText=Regex.Replace(ArticleText, @"(?i)(\[\[(?:[^\]]{1,20},\s(?:Georgia|Washington))\|(?:[^\]]{1,20})\]\]),?\s\[\[(?:Georgia|Washington) \(U. ?S.? state\)\|(Georgia|Washington)\]\]", "$1, $2");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\[\[(?:Brooklyn|Queens|Manhattan|The Bronx))\,\s(New York)\]\]", "$1]], $2");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(New York( City|)(?:\]\], \[\[|, )(?:New York|NY))\]\]", "New York City");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(New York( City|)(?:, (?:New York|NY)|))\|New York\]\](, New York|, \[\[New York\]\]|)", "New York City");
ArticleText=Regex.Replace(ArticleText, @"(?i)New York(?: City|), (?:New York|U\.S\.|USA?)", "New York City");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(London, England)\]\](?:, UK|, United Kingdom|)", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(London)(?:, UK|, United Kingdom)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(London)\|\1, (?:[^\[\]]*)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(?:Chinese|Dutch|English|French|German|Irish|Italian|British|Japanese|Scottish|Spanish|American)\s\(?(?:language|people)\)?\|([^\]]*)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(Chinese|Dutch|English|French|German|Irish|Italian|British|Japanese|Scottish|Spanish|American)(\slanguage|)\]\]", "$1$2"); //unpiped
// months
//time and seasons
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(age|epoch|era|times)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[Present\s\(time\)\|([^\]]+?)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(annual|da[iy]|month|(?:fort|)night|season(?:al|)|hour|minute|present|second|week|year|decade|century)([ -]?end|ly|s|)\]\]", "$1$2");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[((Mon|Tues|Wednes|Thurs|Fri|Satur|Sun)days?)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(?:(?:Mon|Tues|Wednes|Thurs|Fri|Satur|Sun)day)\|(Mon|Tues?|Wed|Thurs?|Fri|Sat|Sun|M|Tu|W|Th|F|Sa|Su)(\.|)\]\]", "$1$2");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(morning|afternoon|midnight|noon|sunrise|sunset|dawn|dusk|twilight)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(spring|summer|winter|autumn|fall)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[spring\s\(season\)\|([^\]]+?)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[autumn\|(fall)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(?:(?:hour|minute|second)s?\||)(hr|min|sec|m|s)\]\]", "$1");
// months
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(Jan(?:uary|\.)|Feb(?:ruary|\.)|Mar(?:ch|\.)|Apr(?:il|\.)|May|Jun(?:e|\.)|Jul(?:y|\.)|Aug(?:ust|\.)|Sep(?:tember|\.|t\.?)|Oct(?:ober|\.)|Nov(?:ember|\.)|Dec(?:ember|\.))\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December)\|([^\]]{1,30})\]\]", "$1");
// simple words and numbers
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(\d{1,3}(,\d{3})*)\]\]", "$1");
// expressions in foreign languages
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(ad (?:hoc|hominem|nauseum)|de facto|et al\.?|fait accompli|faux pas|prima facie|status quo)\]\]", "$1");
// people general, professions
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(apprentice|arranger|art(?:ist|)|athlete|athletics|author|ballet|butcher|camera|career|comedian|composer|consul(?:ate|ar|tant|)|civilian|crew|(?:film |music |)critic|cultur(?:e|al)|dentist|design(?:er|)|dj|(?:dis[ck] |)jockey|drawing|educator|[eé]lite|embassy|engineer(?:ing|)|exhibition|explorer|fishing|group|guest star|hacker|leader|librar(?:ian|ie|y)|lyricist|mayor|mathematic(?:al|ian|s)|music(?:al(?: theatre|theater|)|ian|)|multi-instrumentalist|narrator|panorama|playwright|postage(?: stamp|)|postman|produc(?:e[dr]|tion)|pseudonym|political commentator|pundit|(?:record )company|sailor|sculpt(?:or|ure)|soldier|solicitor|singer.songwriter|song|songwriter|songwriting|toy|tradition|trainee|trumpet(?:er|)|waiter)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(?:(?:edit(?:or|ing)|journalism)\||)(columnists?|edit(?:ed|ing|ors?)|editors?-in-chief|editorial|reporter|journalis[mt]s?)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(?:(?:auto|)biography\||)((?:auto|)biograph(?:er|y|ical|ies))\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(?:philosophy\||)(philosoph(?:er|y|ical|ies))\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(?:science\||)(scien(?:ce|tific(?:ally)|tists?))\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(?:screenwrit(?:er|ing)\||)((?:screen[ -]?|)writ(?:ers?|ing))\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(?:publi(?:cation|shing)\||)(publi(?:cation|shing|shers?))\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(?:photograph(?:er|y|)\||)(photograph(?:ers?|y|ic|s|))\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(?:conducting\||)(conduct(?:ed|ing|ors?))\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(?:(?:piano|pianist)\||)(pianos?|pianists?)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(?:prostitution\||)(prostitut(?:es?|ion))\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(?:politic(?:s|ian)\||)(politic(?:s|al|ians?))\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(?:professional sports\||)(professional|professional sports?)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(?:amateur sports\||)(amateur|amateur sports?)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(?:movie theater\||)(movie theat(?:re|er)s?|cinemas?)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(?:retirement\||)(retir(?:e[drs]?|ement|ing))\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"\[\[(?:[Cc]ivil\s[Ss]ervice\||)(?:[Cc]ivil\s[Ss]erv(ants?|ice))\]\]", "civil serv$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(cable |satellite |terrestrial |)(tv|television)\]\]", "$1$2");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(clothing|cloth(?:es|)|cotton|denim|earring|fabric|footwear|garment|glove|hand ?bag|hat|jean|leather|legging|lingerie|silk|necklace|nylon|dress|tailor|(?:neck|)tie|shirt|sock|stocking|jacket|jewel(?:le|)ry|trouser|vest|watch|scarf|shoe|short|sunglasses|suit|wig)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(balm|eye.?liner|lip.?stick|mascara|perfume)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(?:cosmetics\||)(make.?up|cosmetics)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(?:(?:coats?|belts?)\(clothing\)\||)(coats?|belts?)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(?:ring \(jewel(?:le|)ry\)\||)((?:diamond |engagement |gold |pinkie |wedding |)rings?)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(captain|major|general|lieutenant|private)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(?:(?:captain|colonel|major|general(?: officer|)|lieutenant|sergeant|private)(?: \([\w]*\)|)\||)(captain|colonel|major|general|lieutenant|sergeant|private)\]\](?= \[)", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[musical theatre\|(music(?:al(?: theatre|theater|)s?))\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(beauty (?:competition|contest|pageant|queen))\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(answer|question|contest|contestant|game|pageant)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(?:competition\||)(competit(?:ions?|ive|ors?))\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(?:(?:dance|choreography)\||)(choreograph(?:e[dr]s?|y|)|dance[drs]?|dancing)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(?:(?:(?:paint|writ)ing|illustration)\||)(paint|writ|illustrat)(ed|[eo]rs?|ing)\]\]", "$1$2");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(bicycle|bike|boat|ferry|engine|motor(?:cycle|ing|)|ship|truck|tyre|van|vehicle|wheel)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(van)\]\]", "$1"); //false positive for 'Vans' clothing brand
// ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(foo bar)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(equipment|instrument|machine|tool)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\W\s+)\[\[(?:Ship naming and launching\|)(launched)\]\]", "$1$2");
//business & legal
ArticleText=Regex.Replace(ArticleText, @"\[\[(?:(?:chair \(official\)|chairman)\||)(chair(?:man|woman|person|))\]\]", "chairman");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(chair(?:m[ae]n|person)|contracts?|director|entrepreneur|intellectual property|judge|patent|(?:vice[- ]|)president|real estate|regulation|taxe?|taxation|trademark|treasurer)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(legisla(?:tion|tive assembl[iy]e?|tive council|ture))\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(?:accountancy\||)(account(?:ant|ing))\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(?:business\||)((?:business|enterprise)(?:e?s|))\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(?:business(?:person|people|)\||)(business(?: ?m[ae]n|person|es|))\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(?:(?:law|lawyer)\||)(attorney|laws?|lawyers?|(?:il|)legal(?:ly|))\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(?:board of directors\||)(board|(?:board of |)directors)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[((?:creative|managing|musical|personnel) director)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(?:film ?making\||)(film ?mak(?:er|ing))\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(?:management\||)(manag(?:e[drs]?|ement|ing))\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[((?:private(?:ly held|) |public |listed |quoted |)(?:compan(?:ies|y)|corporations?))\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[((?:private(?:ly held|) |public |listed |quoted )compan(?:ies|y))\|(private|public|listed|quoted)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(?:chief executive officer\||)(CEO|C\.E\.O\.|chief executive( officer)?)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(?:chief (?:financial|operating) officer\||)(C[FO]O|C\.[FO]\.O\.|chief (financial|operating) officer)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(headquarter|officer?|official)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(?:bankruptcy\||)(bankrupt(?:cy|cies|))\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(?:resignation\||)(resign(?:ed|ing|ations?|s|))\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(?:strategy\||)(strateg(?:y|ies|ic|ically))\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(?:(?:trade|trading|commerce)\||)(trade|trading|commerce|commercial)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(?:customs\||)(customs(?: duty| duties| officer| service| tax|))\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(customers?)\]\]", "$1");
// buildings structure and environment
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(bath|bathroom|bed|ceiling|chair|fixture|fitting|gym|kitchen|laundry|shower|(?:swimming |)pool|table|toilet|wall)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(architect(?:ure|)|carpet|cathedral|chapel|construction|fa[cç]ade|floor|furniture|garden(?:ing|)|hospital|home|residen(?:ce|t)|hotel|hous(?:e|ing)|infrastructure|landmark|museum|neighbou?rhood|night club|park|roof|shop(?:ping mall|ping arcade|)|stadium|store?y|skyscraper|interior design(?:er|))\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(?:shopping (?:arcade|mall|centre|center)\||)((?:shopping |)(?:arcade|centre|center|mall)(?:s|))\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(?:church \(building\)\||)(church)(es|)\]\]", "$1$2");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(brick|building|composite|cement|concrete|environment|foundation|glass|steel|structure|wood)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(flat|apartment|room)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(?:garage \(house\)\||)(garages?)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(dam|port|bridge|station|pedestrian|reservoir|road|street|traffic|tunnel|underground|(?:high|free|motor)way)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[((?:high|mid|medium|low)[- ]?rise)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(?:headquarters\||)(headquarters|headquartered)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(?:central business district\|)(CBD|central business district|down[ -]?town)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(CBD|central business district|down[-]?town)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[((?:bus|metro|railway|train|tube|underground)(?: stop| station))\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(?:bus|metro|railway|train|tube|underground)(?: stop| station)\|(station)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(?:environmentalism\||)(environment(?:al(is[mt]|)))\]\]", "$1");
// ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(foobar)\]\]", "$1");