Example #1
0
func ExampleCollect() {
	letter := kern.Regexp(`\pL`)
	digit := kern.Regexp(`\p{Nd}`)

	p := kern.Collect(letter, digit, letter)

	t := utf88.Text("a5bc")
	r, ok := kern.ParseText(p, t)
	if ok {
		fmt.Printf("Result: %c\n", r)
	} else {
		fmt.Printf("Error: %v\n", r)
	}

	// Output:
	// Result: [[a] [5] [b]]
}
Example #2
0
func ExampleAsk() {
	letter := kern.Regexp(`\pL`)
	digit := kern.Regexp(`\p{Nd}`)

	p := kern.Ask(kern.Collect(digit, letter), utf88.Text("digit,letter"))

	t := utf88.Text(";efg")
	r, ok := kern.ParseText(p, t)
	if ok {
		fmt.Printf("Result: %s\n", utf88.Sur(r.(utf88.Codepoint)))
	} else {
		fmt.Printf("Error: %v\n", r)
	}

	// Output:
	// Error: Unexpected ; input. Expecting digit,letter
}