Store multiline mode as a global flag

master
Aadhavan Srinivasan 5 days ago
parent d029a171c0
commit d890a93775

@ -77,6 +77,9 @@ func getPOSIXClass(str []rune) (bool, string) {
// Stores whether the case-insensitive flag has been enabled.
var caseInsensitive bool
// Stores whether the multiline flag has been enabled.
var multilineMode bool
/*
The Shunting-Yard algorithm is used to convert the given infix (regeular) expression to postfix.
The primary benefit of this is getting rid of parentheses.
@ -89,9 +92,11 @@ func shuntingYard(re string, flags ...ReFlag) ([]postfixNode, error) {
// Check which flags are enabled
caseInsensitive = false
multilineMode = false
// In Multiline mode, the newline character is considered a
// 'dot' character ie. the dot metacharacter matches a newline as well.
if slices.Contains(flags, RE_MULTILINE) {
multilineMode = true
notDotChars = []rune{}
} else {
notDotChars = []rune{'\n'}

Loading…
Cancel
Save