Last active
April 17, 2018 03:16
-
-
Save andyarvanitis/1d0a325a6cdb90134934685c140e02d5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Main where | |
import Prelude | |
import Control.Monad.Eff (Eff) | |
import Control.Monad.Eff.Console (CONSOLE, log, logShow) | |
import Data.Either (Either(..)) | |
import Data.Tuple (Tuple) | |
foreign import data PCREOption :: * | |
foreign import data PCRECode :: * | |
foreign import caseless :: PCREOption | |
foreign import dotall :: PCREOption | |
foreign import compile :: String -> Array PCREOption -> Either String PCRECode | |
foreign import capturedCount :: PCRECode -> Int | |
foreign import exec :: PCRECode -> | |
String -> | |
Int -> | |
Array PCREOption -> | |
Int -> | |
Either Int (Array (Tuple Int Int)) | |
main :: forall e. Eff ( console :: CONSOLE | e ) Unit | |
main = do | |
case (compile "^([^!]+)!(.+)=apquxz\\.ixr\\.zzz\\.ac\\.uk$" [caseless]) of | |
Left err -> log err | |
Right pcre -> do | |
let sz = (capturedCount pcre + 1) * 3 | |
result = exec pcre "abc!pqr=apquxz.ixr.zzz.ac.uk" 0 [] sz | |
logShow result | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment