3

Text.Regex.Posix's =~ operator cannot get the return value in some patterns.

For example,

> import Text.Regex.Posix
> "y2019m10d08" =~ "y([0-9]{4})?m([0-9]{1,2})?d([0-9]{1,2})?" :: Bool 
True
> "y2019m10d08" =~ "y([0-9]{4})?m([0-9]{1,2})?d([0-9]{1,2})?" :: Int 
1
> "y2019m10d08" =~ "y([0-9]{4})?m([0-9]{1,2})?d([0-9]{1,2})?" :: [[String]]

What I expected

[["y2019m10d08","2019","10","08"]]

But after the last entry, the calculation doesn't seem to end.

Why?

My environment:

  • Windows 10
  • GHC 8.6.5
  • regex-base-0.93.2
  • regex-posix-0.95.2
satun
  • 31
  • 2
  • 1
    It works as you expected on macOS 10.14.6 with Stackage LTS 14.7 (GHC 8.6.5, regex-base-0.93.2, regex-posix-0.95.2). – snak Oct 08 '19 at 01:12
  • 1
    It also works as you expected on Archlinux using the same GHC and package versions. I got the answer immediately. – JoL Oct 08 '19 at 01:15

1 Answers1

0

Given both the comments and the nature of the package, this is likely to be due to a bug in the underlying C library on your particular system which provides RegEx logic.

This is not the first bug specific to Windows reported for this package (see here and here). You can open an issue on the regex-posix repository and see if they can find the culprit.

Isaac van Bakel
  • 1,772
  • 10
  • 22