2 Commits

Author SHA1 Message Date
dc53951408 Update package name in import 2025-01-30 09:15:44 -05:00
aef8152fc1 Renamed package 'greg' to 'regex' 2025-01-30 09:15:29 -05:00
14 changed files with 17 additions and 17 deletions

View File

@@ -9,12 +9,12 @@ import (
"github.com/fatih/color" "github.com/fatih/color"
"gitea.twomorecents.org/Rockingcool/kg/greg" reg "gitea.twomorecents.org/Rockingcool/kg/regex"
) )
func main() { func main() {
// Flags for the regex Compile function // Flags for the regex Compile function
flagsToCompile := make([]greg.ReFlag, 0) flagsToCompile := make([]reg.ReFlag, 0)
invertFlag := flag.Bool("v", false, "Invert match.") invertFlag := flag.Bool("v", false, "Invert match.")
// This flag has two 'modes': // This flag has two 'modes':
@@ -31,10 +31,10 @@ func main() {
// These flags have to be passed to the Compile function // These flags have to be passed to the Compile function
if *multiLineFlag { if *multiLineFlag {
flagsToCompile = append(flagsToCompile, greg.RE_MULTILINE, greg.RE_SINGLE_LINE) flagsToCompile = append(flagsToCompile, reg.RE_MULTILINE, reg.RE_SINGLE_LINE)
} }
if *caseInsensitiveFlag { if *caseInsensitiveFlag {
flagsToCompile = append(flagsToCompile, greg.RE_CASE_INSENSITIVE) flagsToCompile = append(flagsToCompile, reg.RE_CASE_INSENSITIVE)
} }
// -l and -o are mutually exclusive: -o overrides -l // -l and -o are mutually exclusive: -o overrides -l
@@ -78,7 +78,7 @@ func main() {
reader := bufio.NewReader(os.Stdin) reader := bufio.NewReader(os.Stdin)
out := bufio.NewWriter(os.Stdout) out := bufio.NewWriter(os.Stdout)
regComp, err := greg.Compile(re, flagsToCompile...) regComp, err := reg.Compile(re, flagsToCompile...)
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
return return
@@ -119,14 +119,14 @@ func main() {
panic(err) panic(err)
} }
} }
matchIndices := make([]greg.Match, 0) matchIndices := make([]reg.Match, 0)
if matchNumFlagEnabled { if matchNumFlagEnabled {
tmp, err := greg.FindNthMatch(regComp, test_str, *matchNum) tmp, err := reg.FindNthMatch(regComp, test_str, *matchNum)
if err == nil { if err == nil {
matchIndices = append(matchIndices, tmp) matchIndices = append(matchIndices, tmp)
} }
} else { } else {
matchIndices = greg.FindAllMatches(regComp, test_str) matchIndices = reg.FindAllMatches(regComp, test_str)
} }
if *printMatchesFlag { if *printMatchesFlag {

View File

@@ -1,4 +1,4 @@
package greg package regex
import ( import (
"fmt" "fmt"

View File

@@ -1,4 +1,4 @@
package greg package regex
import ( import (
"fmt" "fmt"

View File

@@ -1,4 +1,4 @@
package greg package regex
import ( import (
"slices" "slices"

View File

@@ -1,4 +1,4 @@
package greg package regex
import ( import (
"fmt" "fmt"

View File

@@ -1,4 +1,4 @@
package greg package regex
import "fmt" import "fmt"

View File

@@ -1,4 +1,4 @@
package greg package regex
import ( import (
"fmt" "fmt"

View File

@@ -1,4 +1,4 @@
package greg package regex
import ( import (
"fmt" "fmt"

View File

@@ -1,4 +1,4 @@
package greg package regex
import "errors" import "errors"

View File

@@ -1,4 +1,4 @@
package greg package regex
type stateContents []int // Represents the contents of the current state - character classes can have multiple contents, which is why it is represented as a slice type stateContents []int // Represents the contents of the current state - character classes can have multiple contents, which is why it is represented as a slice