skylighting-core-0.8.5: syntax highlighting library
Safe HaskellNone
LanguageHaskell2010

Skylighting.Regex

Synopsis

Documentation

data Regex Source #

A compiled regular expression

data RegexException Source #

An exception in compiling or executing a regex.

Instances

Instances details
Show RegexException Source # 
Instance details

Defined in Skylighting.Regex

Generic RegexException Source # 
Instance details

Defined in Skylighting.Regex

Associated Types

type Rep RegexException :: Type -> Type Source #

Exception RegexException Source # 
Instance details

Defined in Skylighting.Regex

type Rep RegexException Source # 
Instance details

Defined in Skylighting.Regex

type Rep RegexException = D1 ('MetaData "RegexException" "Skylighting.Regex" "skylighting-core-0.8.5-DeyPZBI7kohB0tMTaLDdRi" 'True) (C1 ('MetaCons "RegexException" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String)))

data RE Source #

A representation of a regular expression.

Constructors

RE 

Instances

Instances details
Eq RE Source # 
Instance details

Defined in Skylighting.Regex

Methods

(==) :: RE -> RE -> Bool Source #

(/=) :: RE -> RE -> Bool 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 #

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 #

Read RE Source # 
Instance details

Defined in Skylighting.Regex

Show RE Source # 
Instance details

Defined in Skylighting.Regex

Generic RE Source # 
Instance details

Defined in Skylighting.Regex

Associated Types

type Rep RE :: Type -> Type Source #

Methods

from :: RE -> Rep RE x Source #

to :: Rep RE x -> RE Source #

ToJSON RE Source # 
Instance details

Defined in Skylighting.Regex

FromJSON RE Source # 
Instance details

Defined in Skylighting.Regex

Binary RE Source # 
Instance details

Defined in Skylighting.Regex

Methods

put :: RE -> Put Source #

get :: Get RE Source #

putList :: [RE] -> Put Source #

type Rep RE Source # 
Instance details

Defined in Skylighting.Regex

type Rep RE = D1 ('MetaData "RE" "Skylighting.Regex" "skylighting-core-0.8.5-DeyPZBI7kohB0tMTaLDdRi" 'False) (C1 ('MetaCons "RE" 'PrefixI 'True) (S1 ('MetaSel ('Just "reString") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString) :*: S1 ('MetaSel ('Just "reCaseSensitive") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Bool)))

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

Compile a PCRE regex. If the first parameter is True, the regex is case-sensitive, otherwise caseless. The regex is compiled from a bytestring interpreted as UTF-8. If the regex cannot be compiled, a RegexException is thrown.

matchRegex :: Regex -> ByteString -> Maybe [ByteString] Source #

Match a Regex against a bytestring. Returns Nothing if no match, otherwise Just a nonempty list of bytestrings. The first bytestring in the list is the match, the others the captures, if any. If there are errors in executing the regex, a RegexException is thrown.

convertOctalEscapes :: String -> String Source #

Convert octal escapes to the form pcre wants. Note: need at least pcre 8.34 for the form o{dddd}. So we prefer ddd or x{...}.