Added case-insensitve flag

master
Aadhavan Srinivasan 4 weeks ago
parent 924e2a8dbc
commit c87a4b7136

@ -16,6 +16,7 @@ import (
const CONCAT rune = '~'
var notDotChars []rune
var caseInsensitiveFlag *bool // Whether we are running in case-insensitive mode
func isOperator(c rune) bool {
if c == '+' || c == '?' || c == '*' || c == '|' || c == CONCAT {
@ -155,7 +156,11 @@ func shuntingYard(re string) []postfixNode {
*/
c := re_postfix[i]
if isNormalChar(c) {
if *caseInsensitiveFlag {
outQueue = append(outQueue, newPostfixNode(allCases(c)...))
} else {
outQueue = append(outQueue, newPostfixNode(c))
}
continue
}
// Escape character
@ -501,6 +506,7 @@ func main() {
lineFlag := flag.Bool("l", false, "Only print lines with a match (or with no matches, if -v is enabled). Similar to grep's default.")
multiLineFlag := flag.Bool("t", false, "Multi-line mode. Treats newline just like any character.")
printMatchesFlag := flag.Bool("p", false, "Prints start and end index of each match. Can only be used with '-t' for multi-line mode.")
caseInsensitiveFlag = flag.Bool("i", false, "Case-insensitive. Disregard the case of all characters.")
flag.Parse()
// In multi-line mode, 'dot' metacharacter also matches newline

Loading…
Cancel
Save