Skip to content

Commit

Permalink
Add escaping functions (fixes #37)
Browse files Browse the repository at this point in the history
  • Loading branch information
cdornan committed Mar 5, 2017
1 parent e1d229a commit 1903ca0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
26 changes: 15 additions & 11 deletions Text/RE/Internal/EscapeREString.hs
Expand Up @@ -8,14 +8,18 @@ escapeREString = foldr esc []

isMetaChar :: Char -> Bool
isMetaChar c = case c of
'*' -> True
'?' -> True
'+' -> True
'[' -> True
']' -> True
'{' -> True
'}' -> True
'$' -> True
'^' -> True
'.' -> True
_ -> False
'^' -> True
'\\' -> True
'.' -> True
'|' -> True
'*' -> True
'?' -> True
'+' -> True
'(' -> True
')' -> True
'[' -> True
']' -> True
'{' -> True
'}' -> True
'$' -> True
_ -> False
2 changes: 1 addition & 1 deletion examples/re-tests.lhs
Expand Up @@ -424,7 +424,7 @@ escapeTests = testGroup "Escape Tests"
tst esc (%=~) s = matched $ s %=~ esc (("^" ++) . (++ "$")) s
metacharacters :: String
metacharacters = "^*+?[]{}$."
metacharacters = "^\\.|*+?()[]{}$"
\end{code}


Expand Down

0 comments on commit 1903ca0

Please sign in to comment.