aboutsummaryrefslogtreecommitdiffstats
path: root/todolist/parser.go
diff options
context:
space:
mode:
authorQuey-Liang Kao <nonerkao@gmail.com>2017-01-26 20:42:37 +0800
committerQuey-Liang Kao <nonerkao@gmail.com>2017-01-26 20:42:37 +0800
commit50d0119567d2dcae7729bf4e7a841702ba9171d0 (patch)
tree5f7beaed61bd161a2d3b593c7f9136bf18fa889c /todolist/parser.go
parentbfd33a9904daac273ff2b708d02c738be276b8c7 (diff)
Support UTF-8 strings as contexts and projects
Diffstat (limited to 'todolist/parser.go')
-rw-r--r--todolist/parser.go11
1 files changed, 6 insertions, 5 deletions
diff --git a/todolist/parser.go b/todolist/parser.go
index 3ad3aae..6cf1967 100644
--- a/todolist/parser.go
+++ b/todolist/parser.go
@@ -40,23 +40,24 @@ func (p *Parser) Subject(input string) string {
}
func (p *Parser) ExpandProject(input string) string {
- r, _ := regexp.Compile(`(ex|expand) +\d+ +\+\w+[^:]`)
- newProject := r.FindString(input)
- if len(newProject) == 0 {
+ r, _ := regexp.Compile(`(ex|expand) +\d+ +\+[\p{L}\d_]+:`)
+ pattern := r.FindString(input)
+ if len(pattern) == 0 {
return ""
}
+ newProject := pattern[0 : len(pattern)-1]
project := strings.Split(newProject, " ")
return project[len(project)-1]
}
func (p *Parser) Projects(input string) []string {
- r, _ := regexp.Compile(`\+\w+`)
+ r, _ := regexp.Compile(`\+[\p{L}\d_]+`)
return p.matchWords(input, r)
}
func (p *Parser) Contexts(input string) []string {
- r, err := regexp.Compile(`\@\w+`)
+ r, err := regexp.Compile(`\@[\p{L}\d_]+`)
if err != nil {
fmt.Println("regex error", err)
}