mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
regex: define the predicate matches_string (#11422)
This commit is contained in:
parent
f2f7abe2f4
commit
2533f06e1b
@ -556,6 +556,13 @@ fn test_regex(){
|
||||
continue
|
||||
}
|
||||
|
||||
// test the match predicate
|
||||
if to.s >= 0 {
|
||||
assert re.matches_string(to.src)
|
||||
} else {
|
||||
assert !re.matches_string(to.src)
|
||||
}
|
||||
|
||||
// rerun to test consistency
|
||||
tmp_str1 := to.src.clone()
|
||||
start1, end1 := re.match_string(tmp_str1)
|
||||
@ -637,4 +644,4 @@ fn test_quantifier_sequences(){
|
||||
}
|
||||
assert re_err == regex.err_syntax_error
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -144,6 +144,12 @@ pub fn (mut re RE) match_string(in_txt string) (int, int) {
|
||||
return start, end
|
||||
}
|
||||
|
||||
// matches_string Checks if the pattern matches the in_txt string
|
||||
pub fn (mut re RE) matches_string(in_txt string) bool {
|
||||
start, _ := re.match_string(in_txt)
|
||||
return start != no_match_found
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* Finders
|
||||
|
Loading…
Reference in New Issue
Block a user