1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

regex: fix for last group with OR inside (#16324)

This commit is contained in:
penguindark 2022-11-04 07:19:33 +01:00 committed by GitHub
parent fd4045931a
commit eb0c46e13a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 0 deletions

View File

@ -1931,6 +1931,12 @@ pub fn (mut re RE) match_base(in_txt &u8, in_txt_len int) (int, int) {
}
// println("No good exit!!")
if re.prog[re.prog_len - 1].ist == regex.ist_group_end {
// println("last ist is a group end!")
if re.prog[re.prog_len - 1].group_rep >= re.prog[re.prog_len - 1].rep_min {
return state.first_match, state.i
}
}
return regex.no_match_found, state.i
}

View File

@ -376,6 +376,12 @@ find_all_test_suite = [
r"([^\n]*)",
[0, 2],
['ab']
},
Test_find_all{
"ab",
r"([^\n]|a)*",
[0, 2],
['ab']
}
]