{-# LANGUAGE OverloadedStrings #-} import Text.Regex.PCRE.ByteString import Data.ByteString.Char8 -- For instances of the IsString type class. FTS. import Data.Array (Array) -- Not really needed, unless you want to make certain type signatures -- explicit. -- Gets the before / match / after ByteStrings. _regexec :: IO (Either WrapError (Maybe (ByteString, ByteString, ByteString, [ByteString]))) _regexec = do regex <- _regex regexec regex "abCdefgbChijklmbCno" -- Gets the first match offset and length. _execute :: IO (Either WrapError (Maybe (Array Int (MatchOffset, MatchLength)))) _execute = do regex <- _regex execute regex "abCdefgbChijklmbCno" _regex :: IO Regex _regex = do compiled <- compile compMultiline execBlank "b.(.*?)b." -- These compX and execY settings correspond to defaults defined in -- Text.Regex.PCRE.Wrap case compiled of Right regex -> return regex
2013-03-06 at 1:06 am
Haskell: Text.Regex.PCRE.ByteString
I'm pausing my study of existing regex libraries; I'm somewhat burnt out by the mess that's out there. For what it's worth, I've figured out a mid-level API use-case for PCRE and ByteStrings, which are processed faster than Strings. I haven't been able to get the equivalent use-case to work for the TDFA package.
Subscribe to:
Post Comments
(
Atom
)
No comments :
Post a Comment