regex: added less restrictive use of '-' in CC (#9484)
parent
1b7fd2cf00
commit
3b166d8327
|
@ -69,8 +69,8 @@ and all the digits `\d`.
|
||||||
|
|
||||||
It is possible to mix all the properties of the char class together.
|
It is possible to mix all the properties of the char class together.
|
||||||
|
|
||||||
**Note:** In order to match the `-` (minus) char, it must be located at the first position
|
**Note:** In order to match the `-` (minus) char, it must be preceded by a backslash
|
||||||
in the cc, for example `[-_\d\a]` will match `-` minus, `_`underscore, `\d` numeric chars,
|
in the cc, for example `[\-_\d\a]` will match `-` minus, `_`underscore, `\d` numeric chars,
|
||||||
`\a` lower case chars.
|
`\a` lower case chars.
|
||||||
|
|
||||||
### Meta-chars
|
### Meta-chars
|
||||||
|
|
|
@ -390,7 +390,7 @@ const(
|
||||||
]
|
]
|
||||||
|
|
||||||
// these chars are escape if preceded by a \
|
// these chars are escape if preceded by a \
|
||||||
bsls_escape_list = [`\\`, `|`, `.`, `:`, `*`, `+`, `-`, `{`, `}`, `[`, `]`, `(`, `)`, `?`]
|
bsls_escape_list = [`\\`, `|`, `.`, `:`, `*`, `+`, `-`, `{`, `}`, `[`, `]`, `(`, `)`, `?`, `^`, `!`]
|
||||||
)
|
)
|
||||||
|
|
||||||
enum BSLS_parse_state {
|
enum BSLS_parse_state {
|
||||||
|
@ -613,8 +613,15 @@ fn (mut re RE) parse_char_class(in_txt string, in_i int) (int, int, rune) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if status == .in_bsls {
|
if status == .in_bsls {
|
||||||
|
// manage as a simple char
|
||||||
//println("CC bsls not found [${ch:c}]")
|
//println("CC bsls not found [${ch:c}]")
|
||||||
|
re.cc[tmp_index].cc_type = cc_char
|
||||||
|
re.cc[tmp_index].ch0 = char_tmp
|
||||||
|
re.cc[tmp_index].ch1 = char_tmp
|
||||||
|
i += char_len
|
||||||
|
tmp_index++
|
||||||
status = .in_char
|
status = .in_char
|
||||||
|
continue
|
||||||
}else {
|
}else {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,14 @@ struct TestItem {
|
||||||
|
|
||||||
const(
|
const(
|
||||||
match_test_suite = [
|
match_test_suite = [
|
||||||
|
// minus in CC
|
||||||
|
TestItem{"d.def",r"abc.\.[\w\-]{,100}",-1,0},
|
||||||
|
TestItem{"abc12345.asd",r"abc.\.[\w\-]{,100}",-1,0},
|
||||||
|
TestItem{"abca.exe",r"abc.\.[\w\-]{,100}",0,8},
|
||||||
|
TestItem{"abc2.exe-test_12",r"abc.\.[\w\-]{,100}",0,13},
|
||||||
|
TestItem{"abcdefGHK",r"[a-f]+\A+",0,9},
|
||||||
|
TestItem{"ab-cd-efGHK",r"[a-f\-g]+\A+",0,11},
|
||||||
|
|
||||||
// base OR
|
// base OR
|
||||||
TestItem{"a",r"a|b",0,1},
|
TestItem{"a",r"a|b",0,1},
|
||||||
TestItem{"a",r"b|a",0,1},
|
TestItem{"a",r"b|a",0,1},
|
||||||
|
|
Loading…
Reference in New Issue