File: RawRegex.hs

package info (click to toggle)
haskell-raw-strings-qq 1.1-7
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 68 kB
  • sloc: haskell: 84; makefile: 3
file content (29 lines) | stat: -rw-r--r-- 593 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
{-# LANGUAGE QuasiQuotes #-}

module Main
       where

import Text.Regex.Posix
import Text.RawString.QQ

haystack :: String
haystack = "My e-mail address is user@example.com"

needle :: String
needle = [r|\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,3}|]

multiline :: String
multiline = [r|<HTML>
<HEAD>
<TITLE>Auto-generated html formated source</TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1252">
</HEAD>
<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#ffffff">
<P> </P>
<PRE>|]

main :: IO ()
main = do
  print multiline
  print ""
  print $ ((haystack =~ needle) :: String)