Skip to content

Instantly share code, notes, and snippets.

@theqp
Created November 27, 2020 03:01
Show Gist options
  • Save theqp/98373e203483c65fbd93152a795a91f9 to your computer and use it in GitHub Desktop.
Save theqp/98373e203483c65fbd93152a795a91f9 to your computer and use it in GitHub Desktop.
module RegexReadPrice where
import qualified Data.ByteString.Lazy.Char8 as C
import Data.Function ((&))
import GHC.Arr (Array, elems)
import Text.Regex.TDFA (getAllTextMatches, (=~))
import Control.Arrow ((>>>))
-- >>> matches (C.pack "1")
-- [["1","1"],["",""]]
matches :: C.ByteString -> [[String]]
matches s =
(getAllTextMatches (s =~ "(.*)") :: Array Int (Array Int C.ByteString))
& elems
& fmap (elems >>> fmap C.unpack)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment