Regular expression – Multi-line match in Haskell POSIX

I can’t seem to find suitable documentation on Haskell’s POSIX implementation.
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 =~ "]*id=\"wpTextbox1\"[^ >]*>(.*)" :: 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
"]*id=\"wpTextbox1\" [^>]*>(.*)"

Well, because Text.Regex.Posix defaultCompOpt = compExtended compNewline, its effect is the same as

extractToken body = match regex body where
regex = makeRegexOpts compExtended defaultExecOpt
"]*id=\"wpTextbox1\"[^>]*>(.*) "

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
"]*id=\"wpTextbox1\"[^>]*>(.*) "

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 =~ "]*id=\"wpTextbox1\"[^ >]*>(.*)" :: 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
"]*id=\"wpTextbox1\"[^>]*>(.*)"

Well, because Text.Regex.Posix defaultCompOpt = compExtended compNewline, its effect is the same as

extractToken body = match regex body where 
regex = makeRegexOpts compExtended defaultExecOpt
"]*id=\"wpTextbox1\"[^>]*>(.*)"

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
"]*id=\"wpTextbox1\"[^>]*>(.*)"

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 5416 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.