Handle '\s' correctly in regexps
This commit is contained in:
parent
2a9f51790f
commit
a46f9d950c
2 changed files with 10 additions and 2 deletions
|
|
@ -28,7 +28,7 @@ describe("parse_regex", []() {
|
|||
|
||||
{
|
||||
"character classes",
|
||||
"\\w-\\d",
|
||||
"\\w-\\d-\\s",
|
||||
seq({
|
||||
character({
|
||||
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
|
||||
|
|
@ -38,7 +38,9 @@ describe("parse_regex", []() {
|
|||
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '_',
|
||||
}),
|
||||
character({ '-' }),
|
||||
character({ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' }) })
|
||||
character({ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' }),
|
||||
character({ '-' }),
|
||||
character({ ' ', '\t', '\r', '\n' }) })
|
||||
},
|
||||
|
||||
{
|
||||
|
|
|
|||
|
|
@ -181,6 +181,12 @@ class PatternParser {
|
|||
.include('_');
|
||||
case 'd':
|
||||
return CharacterSet().include('0', '9');
|
||||
case 's':
|
||||
return CharacterSet()
|
||||
.include(' ')
|
||||
.include('\t')
|
||||
.include('\n')
|
||||
.include('\r');
|
||||
case 't':
|
||||
return CharacterSet().include('\t');
|
||||
case 'n':
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue