skylighting-core-0.14.7: syntax highlighting library

Safe Haskell | None
Language | Haskell2010

Skylighting.Regex

Synopsis

- data Regex
  - = MatchAnyChar
  - | MatchDynamic !Int
  - | MatchChar (Char -> Bool)
  - | MatchSome !Regex
  - | MatchAlt !Regex !Regex
  - | MatchConcat !Regex !Regex
  - | MatchCapture !Int !Regex
  - | MatchCaptured !Int
  - | AssertWordBoundary
  - | AssertBeginning
  - | AssertEnd
  - | AssertPositive !Direction !Regex
  - | AssertNegative !Direction !Regex
  - | Possessive !Regex
  - | Lazy !Regex
  - | Subroutine !Int
  - | MatchNull
- data RE
- pattern RE :: ByteString -> Bool -> RE
- reCaseSensitive :: RE -> Bool
- reString :: RE -> ByteString
- compileRE :: RE -> Either String Regex
- compileRegex :: Bool -> ByteString -> Either String Regex
- matchRegex :: Regex -> ByteString -> Maybe (ByteString, IntMap (Int, Int))
- testRegex :: Bool -> String -> String -> Maybe (String, [(Int, String)])
- isWordChar :: Char -> Bool

# Documentation

data Regex Source #

Constructors

MatchAnyChar |
MatchDynamic !Int |
MatchChar (Char -> Bool) |
MatchSome !Regex |
MatchAlt !Regex !Regex |
MatchConcat !Regex !Regex |
MatchCapture !Int !Regex |
MatchCaptured !Int |
AssertWordBoundary |
AssertBeginning |
AssertEnd |
AssertPositive !Direction !Regex |
AssertNegative !Direction !Regex |
Possessive !Regex |
Lazy !Regex |
Subroutine !Int |
MatchNull |

#### Instances

Instances details

Monoid Regex Source # |
Instance details Defined in Regex.KDE.Regex Methods mempty :: Regex Source # mappend :: Regex -> Regex -> Regex Source # mconcat :: [Regex] -> Regex Source #
Semigroup Regex Source # |
Instance details Defined in Regex.KDE.Regex Methods (<>) :: Regex -> Regex -> Regex Source # sconcat :: NonEmpty Regex -> Regex Source # stimes :: Integral b => b -> Regex -> Regex Source #
Show Regex Source # |
Instance details Defined in Regex.KDE.Regex Methods showsPrec :: Int -> Regex -> ShowS Source # show :: Regex -> String Source # showList :: [Regex] -> ShowS Source #

data RE Source #

A representation of a regular expression.

#### Instances

Instances details

FromJSON RE Source # |
Instance details Defined in Skylighting.Regex Methods parseJSON :: Value -> Parser RE Source # parseJSONList :: Value -> Parser [RE] Source # omittedField :: Maybe RE Source #
ToJSON RE Source # |
Instance details Defined in Skylighting.Regex Methods toJSON :: RE -> Value Source # toEncoding :: RE -> Encoding Source # toJSONList :: [RE] -> Value Source # toEncodingList :: [RE] -> Encoding Source # omitField :: RE -> Bool Source #
Binary RE Source # |
Instance details Defined in Skylighting.Regex Methods put :: RE -> Put Source # get :: Get RE Source # putList :: [RE] -> Put Source #
Data RE Source # |

Instance details

Defined in Skylighting.Regex

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> RE -> c RE Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c RE Source #

toConstr :: RE -> Constr Source #

dataTypeOf :: RE -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c RE) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c RE) Source #

gmapT :: (forall b. Data b => b -> b) -> RE -> RE Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> RE -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> RE -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> RE -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> RE -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> RE -> m RE Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> RE -> m RE Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> RE -> m RE Source #

Read RE Source # |
Instance details Defined in Skylighting.Regex Methods readsPrec :: Int -> ReadS RE Source # readList :: ReadS [RE] Source # readPrec :: ReadPrec RE Source # readListPrec :: ReadPrec [RE] Source #
Show RE Source # |
Instance details Defined in Skylighting.Regex Methods showsPrec :: Int -> RE -> ShowS Source # show :: RE -> String Source # showList :: [RE] -> ShowS Source #
Eq RE Source # |
Instance details Defined in Skylighting.Regex Methods (==) :: RE -> RE -> Bool Source # (/=) :: RE -> RE -> Bool Source #
Ord RE Source # |
Instance details Defined in Skylighting.Regex Methods compare :: RE -> RE -> Ordering Source # (<) :: RE -> RE -> Bool Source # (<=) :: RE -> RE -> Bool Source # (>) :: RE -> RE -> Bool Source # (>=) :: RE -> RE -> Bool Source # max :: RE -> RE -> RE Source # min :: RE -> RE -> RE Source #

pattern RE :: ByteString -> Bool -> RE Source #

reCaseSensitive :: RE -> Bool Source #

reString :: RE -> ByteString Source #

compileRE :: RE -> Either String Regex Source #

compileRegex :: Bool -> ByteString -> Either String Regex Source #

Compile a UTF-8 encoded ByteString as a Regex. If the first parameter is True, then the Regex will be case sensitive.

matchRegex :: Regex -> ByteString -> Maybe (ByteString, IntMap (Int, Int)) Source #

Match a Regex against a (presumed UTF-8 encoded) ByteString, returning the matched text and a map of (offset, size) pairs for captures. Note that all matches are from the beginning of the string (a `^` anchor is implicit). Note also that to avoid pathological performance in certain cases, the matcher is limited to considering 2000 possible matches at a time; when that threshold is reached, it discards smaller matches. Hence certain regexes may incorrectly fail to match: e.g. `a*a{3000}$` on a string of 3000 `a`s.

testRegex :: Bool -> String -> String -> Maybe (String, [(Int, String)]) Source #

isWordChar :: Char -> Bool Source #