cyucelen / marker

🖍️ Marker is the easiest way to match and mark strings for colorful terminal outputs!
MIT License
48 stars 13 forks source link

Closes #10: Add Email matcher #15

Closed johnny-silverhand closed 5 years ago

codecov-io commented 5 years ago

Codecov Report

Merging #15 into master will not change coverage. The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master    #15   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files           3      3           
  Lines          58     63    +5     
=====================================
+ Hits           58     63    +5
Impacted Files Coverage Δ
matcher.go 100% <100%> (ø) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 984a299...407e316. Read the comment docs.

dapryor commented 5 years ago

Since the email regular expression never changes, you could actually compile the regular expression before hand and use the compiled regular expression as a an argument to the MatchRegexp function.

Example:

var (
    emailReg := regexp.MustCompile("[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,64}")
)
...
func MatchEmail() MatcherFunc {
    return MatchRegexp(emailReg)
}

This will eliminate the need to recompile the regular expression every time the MatchEmail function is called.

johnny-silverhand commented 5 years ago

Hi @dapryor Thank you for your reply. Yeah, it's obviously my mistake. Will be fixed soon