splitRegex treats the regex as a delimiter, and does it fact "swallow" the match. Use matchRegexAll instead - e.g.:1 import Text.Regex2 import Control.Applicative34 main :: IO()5 main = do6 myIn <- readFile "Data.dat"7 case (intoEachPt myIn) of8 Nothing -> print "No match"9 Just (a, b, c, d) -> do print a10 print b11 print c1213 intoEachPt :: String -> Maybe (String, String, String, [String])14 intoEachPt = matchRegexAll (mkRegex "20[0-9]{13}AH021")On Sun, Jul 28, 2013 at 5:35 AM, S. H. Aegis <shaegis@gmail.com> wrote:
_______________________________________________Hi.
I'm newbie to Haskell.
I want to get date, it's type is [[String]].
The problem is that "the string that is used in regular expression pattern" is consumed. ie, disappear.
Here is my code.
------------------------------------------------------------
import Text.Regex
import Control.Applicative
main :: IO()
main = do
myIn <- readFile "Data.dat"
print $ lines <$> intoEachPt myIn
intoEachPt :: String -> [String]
intoEachPt = splitRegex (mkRegex "20[0-9]{13}AH021")
-----------------------------------------------------------
How can I fix this?
Data:
....there is many DIGIT.....201306000300001AH02112361640 9.......
Output:
[[....there is many DIGIT..."],["12361640 9......]....]
I hope:
[[....there is many DIGIT..."],["201306000300001AH02112361640 9......]....]
Beginners mailing list
Beginners@haskell.org
http://www.haskell.org/mailman/listinfo/beginners
_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://www.haskell.org/mailman/listinfo/beginners