words' on an empty string should return empty list
This commit is contained in:
parent
8aba692926
commit
33153851e9
@ -87,9 +87,10 @@ escapeQuotes :: String -> String
|
|||||||
escapeQuotes = regexReplace "([\"'])" "\\1"
|
escapeQuotes = regexReplace "([\"'])" "\\1"
|
||||||
|
|
||||||
-- | Quote-aware version of words - don't split on spaces which are inside quotes.
|
-- | Quote-aware version of words - don't split on spaces which are inside quotes.
|
||||||
-- NB correctly handles "a'b" but not "''a''".
|
-- NB correctly handles "a'b" but not "''a''". Can raise an error if parsing fails.
|
||||||
words' :: String -> [String]
|
words' :: String -> [String]
|
||||||
words' = map stripquotes . fromparse . parsewith p
|
words' "" = []
|
||||||
|
words' s = map stripquotes $ fromparse $ parsewith p s
|
||||||
where
|
where
|
||||||
p = do ss <- (quotedPattern <|> pattern) `sepBy` many1 spacenonewline
|
p = do ss <- (quotedPattern <|> pattern) `sepBy` many1 spacenonewline
|
||||||
-- eof
|
-- eof
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user