fix: alias: Allow escaped characters in regular expression aliases. (#982)
This commit is contained in:
parent
852ba7b100
commit
a65e64115a
@ -1515,11 +1515,12 @@ basicaliasp = do
|
|||||||
regexaliasp :: TextParser m AccountAlias
|
regexaliasp :: TextParser m AccountAlias
|
||||||
regexaliasp = do
|
regexaliasp = do
|
||||||
-- dbgparse 0 "regexaliasp"
|
-- dbgparse 0 "regexaliasp"
|
||||||
char '/'
|
(off1, off2, re) <- between (char '/') (char '/') $ do
|
||||||
off1 <- getOffset
|
off1 <- getOffset
|
||||||
re <- some $ noneOf ("/\n\r" :: [Char]) -- paranoid: don't try to read past line end
|
re <- some $ noneOf ("/\\\n\r" :: [Char]) -- paranoid: don't try to read past line end
|
||||||
off2 <- getOffset
|
<|> (char '\\' *> anySingle) -- allow escaping any character
|
||||||
char '/'
|
off2 <- getOffset
|
||||||
|
return (off1, off2, re)
|
||||||
skipNonNewlineSpaces
|
skipNonNewlineSpaces
|
||||||
char '='
|
char '='
|
||||||
skipNonNewlineSpaces
|
skipNonNewlineSpaces
|
||||||
|
|||||||
@ -252,3 +252,18 @@ $ hledger -f- --alias old="new USD" print | hledger -f- print
|
|||||||
other
|
other
|
||||||
|
|
||||||
>=0
|
>=0
|
||||||
|
|
||||||
|
# 18. Make sure you can match forward slashes in regexps by escaping them. (#982)
|
||||||
|
<
|
||||||
|
alias /\// = :
|
||||||
|
|
||||||
|
2021-01-01
|
||||||
|
hi/there 1
|
||||||
|
b
|
||||||
|
|
||||||
|
$ hledger -f- print
|
||||||
|
2021-01-01
|
||||||
|
hi:there 1
|
||||||
|
b
|
||||||
|
|
||||||
|
>=0
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user