@@ -21,7 +21,7 @@ pub fn regex_base(pattern string) (RE, int, int) {
21
21
re.prog = []Token{len: pattern.len + 1 } // max program length, can not be longer then the pattern
22
22
re.cc = []CharClass{len: pattern.len} // can not be more char class the the length of the pattern
23
23
re.group_csave_flag = false // enable continuos group saving
24
- re.group_max_nested = 128 // set max 128 group nested
24
+ re.group_max_nested = pattern.len >> 1 // set max 128 group nested
25
25
re.group_max = pattern.len >> 1 // we can't have more groups than the half of the pattern legth
26
26
27
27
re.group_stack = []int {len: re.group_max, init: - 1 }
@@ -63,7 +63,7 @@ pub fn (re RE) get_group_by_name(in_txt string, group_name string) string {
63
63
// get_group_by_id get a group string by its id
64
64
pub fn (re RE) get_group_by_id (in_txt string , group_id int ) string {
65
65
if group_id < (re.groups.len >> 1 ) {
66
- index := group_id << 1
66
+ index := group_id * 2
67
67
start := re.groups[index]
68
68
end := re.groups[index + 1 ]
69
69
if start > = 0 && end > start {
@@ -76,7 +76,7 @@ pub fn (re RE) get_group_by_id(in_txt string, group_id int) string {
76
76
// get_group_by_id get a group boundaries by its id
77
77
pub fn (re RE) get_group_bounds_by_id (group_id int ) (int , int ) {
78
78
if group_id < re.group_count {
79
- index := group_id << 1
79
+ index := group_id * 2
80
80
return re.groups[index], re.groups[index + 1 ]
81
81
}
82
82
return - 1 , - 1
@@ -366,8 +366,8 @@ pub fn (mut re RE) replace_by_fn(in_txt string, repl_fn FnReplace) string {
366
366
}
367
367
/*
368
368
for g_i in 0 .. re.group_count {
369
- re.groups[g_i << 1 ] += i
370
- re.groups[(g_i << 1 ) + 1] += i
369
+ re.groups[g_i * 2 ] += i
370
+ re.groups[(g_i * 2 ) + 1] += i
371
371
}
372
372
*/
373
373
repl := repl_fn (re, in_txt, s, e)
@@ -428,8 +428,8 @@ pub fn (mut re RE) replace(in_txt string, repl_str string) string {
428
428
}
429
429
/*
430
430
for g_i in 0 .. re.group_count {
431
- re.groups[g_i << 1 ] += i
432
- re.groups[(g_i << 1 ) + 1] += i
431
+ re.groups[g_i * 2 ] += i
432
+ re.groups[(g_i * 2 ) + 1] += i
433
433
}
434
434
*/
435
435
// repl := repl_fn(re, in_txt, s, e)
0 commit comments