-
-
Save theqp/8d38a3997deb3f15f17b1b5be1e996a9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module RegexReadPrice where | |
import qualified Data.ByteString.Lazy.Char8 as C | |
import Data.Function ((&)) | |
import GHC.Arr (Array, elems) | |
import Text.Regex.TDFA (MatchText, getAllTextMatches, (=~)) | |
-- >>> matches (C.pack "1.01") | |
-- [] | |
matches :: C.ByteString -> [MatchText C.ByteString] | |
matches s = | |
(getAllTextMatches (s =~ "(\\d+)\\D(\\d{2})") :: Array Int (MatchText C.ByteString)) | |
& elems |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment