diff --git a/vlib/regex/regex.v b/vlib/regex/regex.v index 16a5c307e9..c6bc1bd83f 100644 --- a/vlib/regex/regex.v +++ b/vlib/regex/regex.v @@ -1998,7 +1998,7 @@ pub fn (mut re RE) match_base(in_txt byteptr, in_txt_len int ) (int,int) { } // check if we must continue or pass to the next IST - if next_check_flag == true { + if next_check_flag == true && re.prog[state.pc+1].ist != ist_prog_end { //println("save the state!!") re.state_list << StateObj { group_index: state.group_index diff --git a/vlib/regex/regex_test.v b/vlib/regex/regex_test.v index 334b3f657b..ce8dcd03ac 100644 --- a/vlib/regex/regex_test.v +++ b/vlib/regex/regex_test.v @@ -141,6 +141,7 @@ match_test_suite = [ // particular groups TestItem{"ababababac", r"ab(.*)(ac)",0,10}, + ] ) @@ -256,6 +257,18 @@ find_all_test_suite = [ r"[Tt]o\w+", [0, 5, 24, 32], ['Today', 'tomorrow'] + }, + Test_find_all{ + "pera\nurl = https://github.com/dario/pig.html\npippo", + r"url *= *https?://[\w./]+", + [5, 44], + ['url = https://github.com/dario/pig.html'] + }, + Test_find_all{ + "pera\nurl = https://github.com/dario/pig.html\npippo", + r"url *= *https?://.*"+'\n', + [5, 45], + ['url = https://github.com/dario/pig.html\n'] } ] )