Move reusable regexp constants to utils.go.
This commit is contained in:
@@ -11,6 +11,19 @@ var filePathSeparatorRegex = regexp.QuoteMeta(string(filepath.Separator))
|
||||
|
||||
var endOfPathRegex, _ = regexp.Compile(`[` + filePathSeparatorRegex + `][^` + filePathSeparatorRegex + `]+$`)
|
||||
|
||||
var lfRegexp = regexp.MustCompile(`\n`)
|
||||
var crRegexp = regexp.MustCompile(`\r`)
|
||||
var crlfRegexp = regexp.MustCompile(`\r\n`)
|
||||
|
||||
var endsWithFinalNewLineRegexp = regexp.MustCompile(`(\n|\r|\r\n)$`)
|
||||
|
||||
var hasIndentationRegexp = regexp.MustCompile(`^[\t ]`)
|
||||
var hasNoIndentationRegexp = regexp.MustCompile(`^([^\t ]|$)`)
|
||||
var indentedWithMixedTabsAndSpacesRegexp = regexp.MustCompile(`^(\t+ +| +\t+)`)
|
||||
var indentedWithTabsRegexp = regexp.MustCompile(`^\t+`)
|
||||
var indentedWithTabsThenCommentLineRegexp = regexp.MustCompile(`^\t+ \*`)
|
||||
var indentedWithSpacesRegexp = regexp.MustCompile(`^ +`)
|
||||
|
||||
func GetParentDir(path string) string {
|
||||
return endOfPathRegex.ReplaceAllString(path, "")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user