From 50d0119567d2dcae7729bf4e7a841702ba9171d0 Mon Sep 17 00:00:00 2001 From: Quey-Liang Kao Date: Thu, 26 Jan 2017 20:42:37 +0800 Subject: Support UTF-8 strings as contexts and projects --- todolist/parser.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'todolist/parser.go') 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) } -- cgit v1.3