-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.html
3840 lines (3686 loc) · 120 KB
/
app.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="Author" content="Laurent LYAUDET">
<meta name="Publisher" content="Laurent LYAUDET">
<meta name="Description"
content="Dev tool to generate a regular expression matching a range of decimal numbers">
<meta name="Keywords"
content="RegExp, regular expression, generator, decimal number, min, max, step">
<title>DecimalsRangeRegexpGenerator</title>
<style>
table.transitions {
border: solid 2px;
border-collapse: collapse;
}
table.transitions td, table.transitions th{
border: solid 2px;
}
</style>
</head>
<body>
<!--
This file is part of DecimalsRangeRegexpGenerator.
DecimalsRangeRegexpGenerator is free software:
you can redistribute it and/or modify it
under the terms of the GNU Affero General Public License
as published by the Free Software Foundation,
either version 3 of the License,
or (at your option) any later version.
DecimalsRangeRegexpGenerator is distributed in the hope
that it will be useful, but WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Affero General Public License for more details.
You should have received a copy of the
GNU Affero General Public License
along with DecimalsRangeRegexpGenerator.
If not, see <https://www.gnu.org/licenses/>
©Copyright 2022 Laurent Lyaudet
-->
<h1>DecimalsRangeRegexpGenerator</h1>
<form>
<h4>Main parameters</h4>
<h5 id="title_achievement_unlocked">
They impact the decimal numbers that can be written.
</h5>
<p id="is_a_number_regexp"></p>
<div>
<label for="min">
Min (optional):
</label>
<input
type="text"
inputmode="numeric"
pattern="(-|\+)?\d+(\.\d+)?"
title="This input has the following pattern: (-|\+)?\d+(\.\d+)?"
id="min"
name="min"
>
<p id="equals_min"></p>
<p id="more_than_min"></p>
<p id="at_least_min"></p>
</div>
<div>
<label for="is_min_excluded">Min excluded: </label>
<input
type="checkbox"
value="1"
id="is_min_excluded"
name="is_min_excluded"
>
</div>
<div>
<label for="max">
Max (optional):
</label>
<input
type="text"
inputmode="numeric"
pattern="(-|\+)?\d+(\.\d+)?"
title="This input has the following pattern: (-|\+)?\d+(\.\d+)?"
id="max"
name="max"
>
<p id="equals_max"></p>
<p id="less_than_max"></p>
<p id="at_most_max"></p>
</div>
<div>
<label for="is_max_excluded">Max excluded: </label>
<input
type="checkbox"
value="1"
id="is_max_excluded"
name="is_max_excluded"
>
</div>
<div>
<label for="step">
Step
(optional, it will default to arbitrary precision and not 1):
</label>
<input
type="text"
inputmode="numeric"
pattern="\d+(\.\d+)?"
title="This input has the following pattern: \d+(\.\d+)?"
id="step"
name="step"
>
<p>
<span style="color: forestgreen">
Efficient for a step that is
a power of your base (default: 10).
</span>
<span style="color: crimson">
Otherwise experimental,
since the general algorithm I use
generates regular expressions
that becomes too big most of the time.
Try 111 = 7 in base 01, or 5 or 0.5 in base 0123456789
for an example
where it works without being excessively long.
Try 0.25 in base 0123456789 for an example
where the current algorithm is too dumb to compute
a short regular expression.
</span>
</p>
</div>
<hr>
<h4>More optional parameters</h4>
<h5>
They impact the formatting of the decimal numbers
that can be written.
</h5>
<div>
<label for="allow_leading_zeros">
Allow leading zeros:
</label>
<input
type="checkbox"
value="1"
id="allow_leading_zeros"
name="allow_leading_zeros"
>
</div>
<div>
<label for="allow_trailing_zeros">
Allow trailing zeros:
</label>
<input
type="checkbox"
value="1"
id="allow_trailing_zeros"
name="allow_trailing_zeros"
>
</div>
<div>
<label for="min_number_of_digits_before_decimal_separator">
Min number of digits before decimal separator:
</label>
<input
type="text"
inputmode="numeric"
pattern="0|[1-9]\d*"
title="This input has the following pattern: 0|[1-9]\d*"
id="min_number_of_digits_before_decimal_separator"
name="min_number_of_digits_before_decimal_separator"
>
</div>
<div>
<label for="max_number_of_digits_before_decimal_separator">
Max number of digits before decimal separator:
</label>
<input
type="text"
inputmode="numeric"
pattern="0|[1-9]\d*"
title="This input has the following pattern: 0|[1-9]\d*"
id="max_number_of_digits_before_decimal_separator"
name="max_number_of_digits_before_decimal_separator"
>
</div>
<div>
<label for="min_number_of_digits_after_decimal_separator">
Min number of digits after decimal separator:
</label>
<input
type="text"
inputmode="numeric"
pattern="0|[1-9]\d*"
title="This input has the following pattern: 0|[1-9]\d*"
id="min_number_of_digits_after_decimal_separator"
name="min_number_of_digits_after_decimal_separator"
>
</div>
<div>
<label for="max_number_of_digits_after_decimal_separator">
Max number of digits after decimal separator:
</label>
<input
type="text"
inputmode="numeric"
pattern="0|[1-9]\d*"
title="This input has the following pattern: 0|[1-9]\d*"
id="max_number_of_digits_after_decimal_separator"
name="max_number_of_digits_after_decimal_separator"
>
</div>
<div>
<label
for="min_number_of_digits_after_decimal_separator_or_no"
>
Do not apply min number of digits after decimal part
if there is no decimal part:
</label>
<input
type="checkbox"
value="1"
id="min_number_of_digits_after_decimal_separator_or_no"
name="min_number_of_digits_after_decimal_separator_or_no"
>
</div>
<div>
<label for="min_number_of_digits">
Min number of digits before or after decimal separator:
</label>
<input
type="text"
inputmode="numeric"
pattern="0|[1-9]\d*"
title="This input has the following pattern: 0|[1-9]\d*"
id="min_number_of_digits"
name="min_number_of_digits"
>
</div>
<div>
<label for="max_number_of_digits">
Max number of digits before or after decimal separator:
</label>
<input
type="text"
inputmode="numeric"
pattern="0|[1-9]\d*"
title="This input has the following pattern: 0|[1-9]\d*"
id="max_number_of_digits"
name="max_number_of_digits"
>
</div>
<div>
<label for="allow_zero_with_minus">
Allow zero to be written with a minus sign:
</label>
<input
type="checkbox"
value="1"
id="allow_zero_with_minus"
name="allow_zero_with_minus"
>
</div>
<div>
<label for="allow_zero_with_plus">
Allow zero to be written with a plus sign:
</label>
<input
type="checkbox"
value="1"
id="allow_zero_with_plus"
name="allow_zero_with_plus"
>
</div>
<div>
<label for="allow_positive_number_with_plus">
Allow numbers above zero to be written with a plus sign:
</label>
<input
type="checkbox"
value="1"
id="allow_positive_number_with_plus"
name="allow_positive_number_with_plus"
>
</div>
<h5>
Here you can break out of base ten,
and use any encoding of numbers using positional notation
with fixed base.
</h5>
<p>
I like "creeping featurism".
Without sabotage, it is easy to add as many features
as you like, for the good of everyone.
Blaming creeping featurism for high maintenance cost
is hypocrisy.
</p>
<div>
<label for="digits">
Digits:
</label>
<input
type="text"
inputmode="text"
id="digits"
name="digits"
onchange="achievement_unlocked()"
>
<p>
A string that defaults to "0123456789";
you may use "01" (base 2)
or "0123456789abcdef" (base 16) for example,
or even "five" for base four ;).
("f" would be your zero, "i" your unit, etc.)
</p>
</div>
<div>
<label for="decimal_separators">
Decimal separators:
</label>
<input
type="text"
inputmode="text"
id="decimal_separators"
name="decimal_separators"
onchange="achievement_unlocked()"
>
<p>
A string that defaults to ".";
you may use "," or ".," for example.
</p>
</div>
<div>
<label for="plus_signs">
Plus signs:
</label>
<input
type="text"
inputmode="text"
id="plus_signs"
name="plus_signs"
onchange="achievement_unlocked()"
>
<p>
A string that defaults to "+";
you may use "p" for example,
or "pl" if you would like to use "p" or "l" as you wish.
</p>
</div>
<div>
<label for="minus_signs">
Minus signs:
</label>
<input
type="text"
inputmode="text"
id="minus_signs"
name="minus_signs"
onchange="achievement_unlocked()"
>
<p>
A string that defaults to "-";
you may use "m" for example,
or "mn" if you would like to use "m" or "n" as you wish.
</p>
</div>
<h5>
Spacing
</h5>
<div>
<label for="spaces_before_sign">
Spaces characters before a sign character:
</label>
<input
type="text"
inputmode="text"
id="spaces_before_sign"
name="spaces_before_sign"
>
</div>
<div>
<label for="min_number_of_spaces_before_sign">
Min number of spaces before a sign character:
</label>
<input
type="text"
inputmode="numeric"
pattern="0|[1-9]\d*"
title="This input has the following pattern: 0|[1-9]\d*"
id="min_number_of_spaces_before_sign"
name="min_number_of_spaces_before_sign"
>
</div>
<div>
<label for="max_number_of_spaces_before_sign">
Max number of spaces before a sign character:
</label>
<input
type="text"
inputmode="numeric"
pattern="0|[1-9]\d*"
title="This input has the following pattern: 0|[1-9]\d*"
id="max_number_of_spaces_before_sign"
name="max_number_of_spaces_before_sign"
>
</div>
<div>
<label for="spaces_before_number">
Spaces characters before a number without sign:
</label>
<input
type="text"
inputmode="text"
id="spaces_before_number"
name="spaces_before_number"
>
</div>
<div>
<label for="min_number_of_spaces_before_number">
Min number of spaces before a number without sign:
</label>
<input
type="text"
inputmode="numeric"
pattern="0|[1-9]\d*"
title="This input has the following pattern: 0|[1-9]\d*"
id="min_number_of_spaces_before_number"
name="min_number_of_spaces_before_number"
>
</div>
<div>
<label for="max_number_of_spaces_before_number">
Max number of spaces before a number without sign:
</label>
<input
type="text"
inputmode="numeric"
pattern="0|[1-9]\d*"
title="This input has the following pattern: 0|[1-9]\d*"
id="max_number_of_spaces_before_number"
name="max_number_of_spaces_before_number"
>
</div>
<div>
<label for="spaces_between_sign_and_number">
Spaces characters between a sign and number:
</label>
<input
type="text"
inputmode="text"
id="spaces_between_sign_and_number"
name="spaces_between_sign_and_number"
>
<p>
You may try exactly one non-breakable space here,
for example.
</p>
</div>
<div>
<label for="min_number_of_spaces_between_sign_and_number">
Min number of spaces between a sign and number:
</label>
<input
type="text"
inputmode="numeric"
pattern="0|[1-9]\d*"
title="This input has the following pattern: 0|[1-9]\d*"
id="min_number_of_spaces_between_sign_and_number"
name="min_number_of_spaces_between_sign_and_number"
>
</div>
<div>
<label for="max_number_of_spaces_between_sign_and_number">
Max number of spaces between a sign and number:
</label>
<input
type="text"
inputmode="numeric"
pattern="0|[1-9]\d*"
title="This input has the following pattern: 0|[1-9]\d*"
id="max_number_of_spaces_between_sign_and_number"
name="max_number_of_spaces_between_sign_and_number"
>
</div>
<div>
<label for="spaces_after_last_digit">
Spaces characters after_last_digit:
</label>
<input
type="text"
inputmode="text"
id="spaces_after_last_digit"
name="spaces_after_last_digit"
>
</div>
<div>
<label for="min_number_of_spaces_after_last_digit">
Min number of spaces after last digit:
</label>
<input
type="text"
inputmode="numeric"
pattern="0|[1-9]\d*"
title="This input has the following pattern: 0|[1-9]\d*"
id="min_number_of_spaces_after_last_digit"
name="min_number_of_spaces_after_last_digit"
>
</div>
<div>
<label for="max_number_of_spaces_after_last_digit">
Max number of spaces after last digit:
</label>
<input
type="text"
inputmode="numeric"
pattern="0|[1-9]\d*"
title="This input has the following pattern: 0|[1-9]\d*"
id="max_number_of_spaces_after_last_digit"
name="max_number_of_spaces_after_last_digit"
>
</div>
<div>
<label for="spaces_inter_digits_before">
Spaces characters between digits before decimal separator:
</label>
<input
type="text"
inputmode="text"
id="spaces_inter_digits_before"
name="spaces_inter_digits_before"
>
</div>
<div>
<label for="min_number_of_spaces_inter_digits_before">
Min number of spaces between digits before decimal separator:
</label>
<input
type="text"
inputmode="numeric"
pattern="0|[1-9]\d*"
title="This input has the following pattern: 0|[1-9]\d*"
id="min_number_of_spaces_inter_digits_before"
name="min_number_of_spaces_inter_digits_before"
>
</div>
<div>
<label for="max_number_of_spaces_inter_digits_before">
Max number of spaces between digits before decimal separator:
</label>
<input
type="text"
inputmode="numeric"
pattern="0|[1-9]\d*"
title="This input has the following pattern: 0|[1-9]\d*"
id="max_number_of_spaces_inter_digits_before"
name="max_number_of_spaces_inter_digits_before"
>
</div>
<div>
<label for="spaces_between_digit_and_decimal_separator">
Spaces characters between digit and decimal separator:
</label>
<input
type="text"
inputmode="text"
id="spaces_between_digit_and_decimal_separator"
name="spaces_between_digit_and_decimal_separator"
>
</div>
<div>
<label
for="min_number_of_spaces_between_digit_and_decimal_separator"
>
Min number of spaces between digit and decimal separator:
</label>
<input
type="text"
inputmode="numeric"
pattern="0|[1-9]\d*"
title="This input has the following pattern: 0|[1-9]\d*"
id="min_number_of_spaces_between_digit_and_decimal_separator"
name="min_number_of_spaces_between_digit_and_decimal_separator"
>
</div>
<div>
<label
for="max_number_of_spaces_between_digit_and_decimal_separator"
>
Max number of spaces between digit and decimal separator:
</label>
<input
type="text"
inputmode="numeric"
pattern="0|[1-9]\d*"
title="This input has the following pattern: 0|[1-9]\d*"
id="max_number_of_spaces_between_digit_and_decimal_separator"
name="max_number_of_spaces_between_digit_and_decimal_separator"
>
</div>
<div>
<label for="spaces_between_decimal_separator_and_digit">
Spaces characters between decimal separator and digit:
</label>
<input
type="text"
inputmode="text"
id="spaces_between_decimal_separator_and_digit"
name="spaces_between_decimal_separator_and_digit"
>
</div>
<div>
<label
for="min_number_of_spaces_between_decimal_separator_and_digit"
>
Min number of spaces between decimal separator and digit:
</label>
<input
type="text"
inputmode="numeric"
pattern="0|[1-9]\d*"
title="This input has the following pattern: 0|[1-9]\d*"
id="min_number_of_spaces_between_decimal_separator_and_digit"
name="min_number_of_spaces_between_decimal_separator_and_digit"
>
</div>
<div>
<label
for="max_number_of_spaces_between_decimal_separator_and_digit"
>
Max number of spaces between decimal separator and digit:
</label>
<input
type="text"
inputmode="numeric"
pattern="0|[1-9]\d*"
title="This input has the following pattern: 0|[1-9]\d*"
id="max_number_of_spaces_between_decimal_separator_and_digit"
name="max_number_of_spaces_between_decimal_separator_and_digit"
>
</div>
<div>
<label for="spaces_inter_digits_after">
Spaces characters between digits after decimal separator:
</label>
<input
type="text"
inputmode="text"
id="spaces_inter_digits_after"
name="spaces_inter_digits_after"
>
</div>
<div>
<label for="min_number_of_spaces_inter_digits_after">
Min number of spaces between digits after decimal separator:
</label>
<input
type="text"
inputmode="numeric"
pattern="0|[1-9]\d*"
title="This input has the following pattern: 0|[1-9]\d*"
id="min_number_of_spaces_inter_digits_after"
name="min_number_of_spaces_inter_digits_after"
>
</div>
<div>
<label for="max_number_of_spaces_inter_digits_after">
Max number of spaces between digits after decimal separator:
</label>
<input
type="text"
inputmode="numeric"
pattern="0|[1-9]\d*"
title="This input has the following pattern: 0|[1-9]\d*"
id="max_number_of_spaces_inter_digits_after"
name="max_number_of_spaces_inter_digits_after"
>
</div>
<div>
<label for="min_number_of_contiguous_digits">
Min number of contiguous digits:
</label>
<input
type="text"
inputmode="numeric"
pattern="[1-9]\d*"
title="This input has the following pattern: [1-9]\d*"
id="min_number_of_contiguous_digits"
name="min_number_of_contiguous_digits"
>
</div>
<div>
<label for="max_number_of_contiguous_digits">
Max number of contiguous digits:
</label>
<input
type="text"
inputmode="numeric"
pattern="[1-9]\d*"
title="This input has the following pattern: [1-9]\d*"
id="max_number_of_contiguous_digits"
name="max_number_of_contiguous_digits"
>
<p>
With both min and max at 3,
you can have spacing like thousands separators.
</p>
</div>
<h5>
More strange things
</h5>
<div>
<label for="regexp_enclosing_start">
Enclose groups in regular expression with:
</label>
<select
id="regexp_enclosing_start"
name="regexp_enclosing_start"
>
<option value="(">"(" for simple capturing group (shorter regular expression)</option>
<option value="(?:">"(?:" for non-capturing group (faster and use less memory)</option>
</select>
<p>
The generated regular expressions sometimes need to use groups,
that are not positive or negative look-ahead or look-behind.
It is used either for alternatives or repetitions.
In that case, one may freely choose to use simple capturing group
or non-capturing group.
</p>
</div>
<div>
<label for="allow_leading_decimal_separator">
<span style="text-decoration-line: line-through;">
Allow leading decimal separator (without any digit before):
</span>
</label>
<input
type="checkbox"
value="1"
id="allow_leading_decimal_separator"
name="allow_leading_decimal_separator"
disabled
>
<p>
You do not need it,
you can use "Min number of digits before decimal separator"
= 0
or empty and a max is given.
Note that when no min and no max are given, it defaults to
"+" or "{1,}"
that disallow leading decimal separator.
Because "+" is the most sensible choice for most use cases.
</p>
</div>
<div>
<label for="allow_trailing_decimal_separator">
<span style="text-decoration-line: line-through;">
Allow trailing decimal separator (without any digit after):
</span>
</label>
<input
type="checkbox"
value="1"
id="allow_trailing_decimal_separator"
name="allow_trailing_decimal_separator"
disabled
>
<p>
You do not need it,
you can use "Min number of digits after decimal separator"
= 0
or empty and a max is given.
Note that when no min and no max are given, it defaults to
"+" or "{1,}"
that disallow trailing decimal separator.
Because "+" is the most sensible choice for most use cases.
If you want to make sure that no trailing decimal separator
is allowed,
while specifying a max number of digits after decimal
use "Min number of digits after decimal separator" = 1
with or without
"Do not apply min number of digits after decimal part
if there is no decimal part".
</p>
</div>
<hr>
<button type="submit">Generate</button>
</form>
<hr>
<h4>Error message</h4>
<div id="error" style="color: red;"></div>
<hr>
<h4>Result</h4>
<div>
<textarea
id="result"
style="width: 100%; box-sizing: border-box;"
onkeyup="result_changed()"
></textarea>
</div>
<hr>
<h4 id="test_your_result">Test your result</h4>
<form action="javascript:test_validated()">
<label for="test_string">
Test string:
</label>
<div>
<input
type="text"
inputmode="text"
id="test_string"
name="test_string"
onkeyup="reinit_test_your_result()"
>
</div>
<button
id="submit_test"
type="submit"
style="display: none;"
>Test</button>
<p>
Note that an empty string will always validate.
If you want to exclude an empty string,
you have to add "required" as an attribute to your HTML input.
</p>
</form>
<hr>
<h4>Detail of step calculus</h4>
<div id="step_calculus">
</div>
<br>
<br>
<hr>
©Copyright 2022 Laurent Lyaudet
<br>
GNU AGPL : this HTML file you're currently viewing
must contain all the source code,
other files of the repository should be <a href=".">here</a>,
or on GitHub
<a href="https://github.com/LLyaudet/DecimalsRangeRegexpGenerator">
here
</a>.
<script>
"use strict";
// This code is from StackOverflow.
// https://stackoverflow.com/a/9251169/5796086
// I can not believe that there is still no HTML.escape()
// and HTML.unescape() functions in JS standard in 2022.
// Seriously !
let escape = document.createElement('textarea');
function escapeHTML(html) {
escape.textContent = html;
return escape.innerHTML;
}
function unescapeHTML(html) {
escape.innerHTML = html;
return escape.textContent;
}
function achievement_unlocked(){
let title_achievement_unlocked_element = (
document.getElementById("title_achievement_unlocked")
);
title_achievement_unlocked_element.innerHTML = (
"<span style=\"color: steelblue\">"
+ "They impact the"
+ " <span style=\"text-decoration-line: line-through;\">"
+ "decimal</span> (achievement unlocked)"
+ " numbers that can be written."
+ "</span>"
);
let minElement = document.getElementById("min");
let maxElement = document.getElementById("max");
let stepElement = document.getElementById("step");
minElement.inputMode = "text";
minElement.removeAttribute("pattern");
minElement.title = "This input has no pattern.";
maxElement.inputMode = "text";
maxElement.removeAttribute("pattern");
maxElement.title = "This input has no pattern.";
stepElement.inputMode = "text";
stepElement.removeAttribute("pattern");
stepElement.title = "This input has no pattern.";
}
function test_validated(){
document.getElementById("test_your_result").innerHTML = (
"<span style=\"color: forestgreen\">"
+ "Test your result: Congratulations it works !"
+ "</span>"
);
}
function reinit_test_your_result(){
document.getElementById("test_your_result").innerHTML = (
"<span style=\"color: crimson\">"
+ "Test your result:"
+ " Congratulations it does not validate your string !"
+ " It may have been your goal anyway :)"
+ "</span>"
);
document.getElementById("submit_test").click();
}
function result_changed(){
let result_regexp = (
document.getElementById("result").value
);
let test_string_element = (
document.getElementById("test_string")
);
test_string_element.pattern = result_regexp;
test_string_element.title = (
"This input has the following pattern: "
+ result_regexp
);
reinit_test_your_result();
document.getElementById("result").focus();
}
const url_search_params = new URLSearchParams(
window.location.search
);
let parameters = {
min: "",
is_min_excluded: false,
max: "",
is_max_excluded: false,
step: "",
allow_leading_zeros: false,
allow_trailing_zeros: false,
min_number_of_digits_before_decimal_separator: null,
max_number_of_digits_before_decimal_separator: null,
min_number_of_digits_after_decimal_separator: null,
max_number_of_digits_after_decimal_separator: null,
min_number_of_digits_after_decimal_separator_or_no: false,
min_number_of_digits: null,
max_number_of_digits: null,
allow_zero_with_minus: false,
allow_zero_with_plus: false,
allow_positive_number_with_plus: false,
digits: "",
decimal_separators: "",
plus_signs: "",
minus_signs: "",
spaces_before_sign: "",
min_number_of_spaces_before_sign: null,
max_number_of_spaces_before_sign: null,
spaces_before_number: "",
min_number_of_spaces_before_number: null,
max_number_of_spaces_before_number: null,
spaces_between_sign_and_number: "",
min_number_of_spaces_between_sign_and_number: null,
max_number_of_spaces_between_sign_and_number: null,
spaces_after_last_digit: "",
min_number_of_spaces_after_last_digit: null,
max_number_of_spaces_after_last_digit: null,
spaces_inter_digits_before: "",
min_number_of_spaces_inter_digits_before: null,
max_number_of_spaces_inter_digits_before: null,
spaces_between_digit_and_decimal_separator: "",
min_number_of_spaces_between_digit_and_decimal_separator: null,
max_number_of_spaces_between_digit_and_decimal_separator: null,
spaces_between_decimal_separator_and_digit: "",
min_number_of_spaces_between_decimal_separator_and_digit: null,
max_number_of_spaces_between_decimal_separator_and_digit: null,
spaces_inter_digits_after: "",
min_number_of_spaces_inter_digits_after: null,
max_number_of_spaces_inter_digits_after: null,
min_number_of_contiguous_digits: null,
max_number_of_contiguous_digits: null,
regexp_enclosing_start: "",
};
let error_message = "";
function set_text_parameter_in_form(parameter_name){