regex-do-2.6.1: PCRE wrapper

Safe HaskellNone
LanguageHaskell2010

Text.Regex.Do.Pcre.Utf8.Match

Description

see Text.Regex.Base.RegexLike and Text.Regex.Do.Pcre.Utf8.MatchHint

similar to Text.Regex.Do.Pcre.Ascii.Match

Pattern & Body are wrapped in Utf8_ encoding tag. This tag adds clarity, prevents calling Ascii functions by mistake.

toByteString' converts String to Utf8_ ByteString

Synopsis

Documentation

class Match enc a b out where Source

Methods

match :: Pattern (enc a) -> Body (enc b) -> out Source

Instances

Rx_ a b => Match Utf8_ a b Bool Source

test. Note that a and b may be different types e.g. ByteString and String

>>> toByteString "в" =~ ("тихо в лесу"::String)::Bool

True

Rx_ a b => Match Utf8_ a b [[PosLen]] Source

match all

Rx_ a b => Match Utf8_ a b [PosLen] Source

match once

>>> ("и"::String) =~ ("бывает и хуже"::String)::[PosLen]

[(13,2)]

Rx_ a b => Match Utf8_ a b [[b]] Source

match all

>>> ("well"::String) =~ ("all is well that ends well"::String)::[[String]]

[["well"],["well"]]

Rx_ a b => Match Utf8_ a b [b] Source

match once

precompiled regex as pattern

>>> let rx1 = makeRegexOpt' (Pattern $ toByteString' "左") [] []      --  add options as needed
        rx2 = Utf8_ <$> rx1
        m1 = U.match rx2 (Body $ toByteString' "100メートル左折後、左")::[ByteString]
     m1 `shouldBe` [toByteString "左"]        

(=~) Source

Arguments

:: Match Utf8_ a b out 
=> a

pattern

-> b

body

-> out 

synonym for match. arg without newtypes

extract :: Extract source => (Int, Int) -> source -> source

extract takes an offset and length and has a default implementation of extract (off,len) source = before len (after off source)

extract is reexport from Text.Regex.Base.RegexLike