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

Viewed 62

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
1 Answers

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.

Related