Especially the module Text. Regex.Posix.
Anyone Can you point me in the right direction to use multi-line matching on strings?
A strange fragment:
> extractToken body = body =~ "" :: String
I am trying to extract the source of a Wikipedia page, but this method obviously fails when multiple lines are involved.
extractToken body = match regex body where
regex = makeRegexOpts (defaultCompOpt-compNewline) defaultExecOpt
""
Well, because Text.Regex.Posix defaultCompOpt = compExtended compNewline, its effect is the same as
p>
extractToken body = match regex body where
regex = makeRegexOpts compExtended defaultExecOpt
""
To extract only the first group, please use one of the other instances of RegexLike
. One possibility is
extractToken body = head groups where
(preMatch, inMatch, postMatch, groups) =
match regex body :: (String, S tring, String, [String])
regex = makeRegexOpts compExtended defaultExecOpt
" "
I can’t seem to find suitable documentation on Haskell’s POSIX implementation.
Especially the module Text. Regex.Posix.
< p>Can anyone point me in the right direction to use multi-line matching on strings?
A strange fragment:
> extractToken body = body =~ "" :: String
I am trying to extract the source of a Wikipedia page, but this method obviously fails when multiple lines are involved.
You may need to import Text.Regex.Base.RegexLike to access makeRegexOpts and friends.
extractToken body = match regex body where
regex = makeRegexOpts (defaultCompOpt-compNewline) defaultExecOpt
"
Well, because Text.Regex.Posix defaultCompOpt = compExtended compNewline, its effect is the same as
extractToken body = match regex body where
regex = makeRegexOpts compExtended defaultExecOpt
""
To extract only the first group, use one of the other instances of RegexLike
. One possibility is
extractToken body = head groups where
(preMatch, inMatch, postMatch, groups) =
match regex body :: (String, String, String, [String])
regex = makeRegexOpts compExt ended defaultExecOpt
""