From 30779a446b7c3bbbed7f1eacc7eb76310f8edee0 Mon Sep 17 00:00:00 2001 From: Aadhavan Srinivasan Date: Fri, 31 Jan 2025 16:46:19 -0500 Subject: [PATCH] Updated documentation --- regex/doc.go | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/regex/doc.go b/regex/doc.go index bef77ec..b9afeba 100644 --- a/regex/doc.go +++ b/regex/doc.go @@ -95,9 +95,25 @@ Numeric ranges: Match any number from x to y (inclusive) (x and y must be positive numbers) -# Flags +# Key Differences with regexp -Flags are used to change the behavior of the engine. None of them are enabled by default. They are passed as variadic arguments to [Compile]. -The list of flags is provided in the type definition for [ReFlag]. +The engine and the API differ from [regexp] in a number of ways, some of them very subtle. +The key differences are mentioned below. + +Greediness: + +This engine does not support non-greedy operators. All operators are always greedy in nature, and will try +to match as much as they can, while still allowing for a successful match. For example, given the regex: + + y*y + +The engine will match as many 'y's as it can, while still allowing the trailing 'y' to be matched. + +Another, more subtle example is the following regex: + + x|xx + +While the stdlib implementation (and most other engines) will prefer matching the first item of the alternation, +my engine will _always_ go for the longest possible match, regardless of the order of the alternation. */ package regex