Skip to content

Commit 73d9955

Browse files
committed
Document that for "usual" regex behavior multiline is required
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: purescript-contrib#231
1 parent c38e6ea commit 73d9955

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Diff for: src/Parsing/String.purs

+4-1
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,9 @@ match p = do
195195

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

0 commit comments

Comments
 (0)