Handle more escaped characters in regexps
This commit is contained in:
parent
4720672cfb
commit
01571da30d
2 changed files with 16 additions and 0 deletions
|
|
@ -126,6 +126,16 @@ describe("parsing regex patterns", []() {
|
|||
})
|
||||
},
|
||||
|
||||
{
|
||||
"escaped characters",
|
||||
"\\t\\n\\r",
|
||||
seq({
|
||||
character({ '\t' }),
|
||||
character({ '\n' }),
|
||||
character({ '\r' }),
|
||||
})
|
||||
},
|
||||
|
||||
{
|
||||
"plus repeats",
|
||||
"(ab)+(cd)+",
|
||||
|
|
|
|||
|
|
@ -174,6 +174,12 @@ class PatternParser {
|
|||
return CharacterSet({ { 'a', 'z' }, { 'A', 'Z' }, { '0', '9' } });
|
||||
case 'd':
|
||||
return CharacterSet({ { '0', '9' } });
|
||||
case 't':
|
||||
return CharacterSet({ '\t' });
|
||||
case 'n':
|
||||
return CharacterSet({ '\n' });
|
||||
case 'r':
|
||||
return CharacterSet({ '\r' });
|
||||
default:
|
||||
return CharacterSet({ value });
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue