mirror of
https://gitee.com/johng/gf
synced 2026-06-07 02:12:11 +08:00
fix example for package gregex
This commit is contained in:
@ -7,6 +7,7 @@ package gregex_test
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
@ -119,10 +120,10 @@ func ExampleMatchAllString() {
|
||||
|
||||
func ExampleQuote() {
|
||||
result := gregex.Quote(`[1-9]\d+`)
|
||||
g.Dump(result)
|
||||
fmt.Println(result)
|
||||
|
||||
// Output:
|
||||
// "\[1-9\]\\d\+"
|
||||
// \[1-9\]\\d\+
|
||||
}
|
||||
|
||||
func ExampleReplace() {
|
||||
@ -268,14 +269,11 @@ func ExampleSplit() {
|
||||
|
||||
func ExampleValidate() {
|
||||
// Valid match statement
|
||||
g.Dump(gregex.Validate(`\d+`))
|
||||
fmt.Println(gregex.Validate(`\d+`))
|
||||
// Mismatched statement
|
||||
g.Dump(gregex.Validate(`[a-9]\d+`))
|
||||
fmt.Println(gregex.Validate(`[a-9]\d+`))
|
||||
|
||||
// Output:
|
||||
// <nil>
|
||||
// {
|
||||
// Code: "invalid character class range",
|
||||
// Expr: "a-9",
|
||||
// }
|
||||
// error parsing regexp: invalid character class range: `a-9`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user