LoginSignup
3
3

More than 5 years have passed since last update.

Googleの正規表現ライブラリre2のGoラッパー

Posted at

GitHubで公開しました

基本的な使い方はregexpパッケージとほぼ同じです。
ただ、こちらはCompile系の関数呼び出し時に終了処理用のCloserを返したり、一部メソッドにRE2というprefixを付けています(理由はREADME.mdに記載しています)。

main.go
package main

import (
    "fmt"
    "github.com/wordijp/golang-re2"
)

func main() {
    re, closer := re2.MustCompile("fo.?")
    defer closer.Close(re)

    fmt.Printf("%q\n", re.FindString("seafood"))
    fmt.Printf("%q\n", re.FindString("meat"))
}

"foo"
""
3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3