Skip to content

Commit

Permalink
Document that for "usual" regex behavior multiline is required
Browse files Browse the repository at this point in the history
Regular expression users typically expect that matching a `$` in a
multiline string would match the end of current line and not the end
of the string past many lines. This is default behavior in pretty much
every regexp engine: `grep`, `perl`, text editors, you name it… So it
is fair to expect such expectation, so warn a user about necessity to
pass `multiline`

Fixes: #231
  • Loading branch information
Hi-Angel committed Oct 15, 2024
1 parent c38e6ea commit 73d9955
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Parsing/String.purs
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,9 @@ match p = do

-- | Compile a regular expression `String` into a regular expression parser.
-- |
-- | Note that per JS RegExp semantics matching a single line in a multiline
-- | string requires passing `multiline` flag rather than `noFlags`.
-- |
-- | This function will use the `Data.String.Regex.regex` function to compile
-- | and return a parser which can be used
-- | in a `ParserT String m` monad.
Expand Down Expand Up @@ -235,7 +238,7 @@ match p = do
-- | capture the regular expression pattern `x*`.
-- |
-- | ```purescript
-- | case regex "x*" noFlags of
-- | case regex "x*" multiline of
-- | Left compileError -> unsafeCrashWith $ "xMany failed to compile: " <> compileError
-- | Right xMany -> runParser "xxxZ" do
-- | xMany
Expand Down

0 comments on commit 73d9955

Please sign in to comment.