mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
23 lines
458 B
V
23 lines
458 B
V
|
import regex
|
||
|
|
||
|
fn test_anchor_start() {
|
||
|
mut re := regex.regex_opt(r'^\w+') or { panic(err) }
|
||
|
start, end := re.find('id.')
|
||
|
assert start == 0
|
||
|
assert end == 2
|
||
|
}
|
||
|
|
||
|
fn test_anchor_end() {
|
||
|
mut re := regex.regex_opt(r'\w+$') or { panic(err) }
|
||
|
start, end := re.find('(id')
|
||
|
assert start == 1
|
||
|
assert end == 3
|
||
|
}
|
||
|
|
||
|
fn test_anchor_both() {
|
||
|
mut re := regex.regex_opt(r'^\w+$') or { panic(err) }
|
||
|
start, end := re.find('(id)')
|
||
|
assert start == -1
|
||
|
assert end == -1
|
||
|
}
|