mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
regex: make match_string() receiver immutable
This commit is contained in:
parent
7c4f45a375
commit
42a9eaac0e
@ -124,7 +124,8 @@ pub fn (re RE) get_group_list() []Re_group {
|
||||
******************************************************************************/
|
||||
// match_string Match the pattern with the in_txt string
|
||||
[direct_array_access]
|
||||
pub fn (mut re RE) match_string(in_txt string) (int, int) {
|
||||
pub fn (re &RE) match_string(in_txt string) (int, int) {
|
||||
unsafe {
|
||||
start, mut end := re.match_base(in_txt.str, in_txt.len + 1)
|
||||
if end > in_txt.len {
|
||||
end = in_txt.len
|
||||
@ -143,10 +144,11 @@ pub fn (mut re RE) match_string(in_txt string) (int, int) {
|
||||
return start, end
|
||||
}
|
||||
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 {
|
||||
pub fn (re &RE) matches_string(in_txt string) bool {
|
||||
start, _ := re.match_string(in_txt)
|
||||
return start != no_match_found
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user