Skip to content

Library for working with hashtags in the text

License

Notifications You must be signed in to change notification settings

itbasis/go-hashtag

Repository files navigation

Go HashTag

Library for working with hashtags in the text

GitHub branch checks state GitHub go.mod Go version godoc reference blue GitHub Release codecov Go Report Card

Installation

go get -u github.com/itbasis/go-hashtag@latest

Examples

Case-insensitive:

package main

import (
	"fmt"

	"github.com/itbasis/go-hashtag"
)

func main() {
  text := "An example of a text with a #hashtag #another #Another"
  hashTags := hashtag.NewParser(false).Parse(text)
  fmt.Println(hashTags)

  // Output: ["hashtag": 1, "another": 2]
}

Case-sensitive:

package main

import (
	"fmt"

	"github.com/itbasis/go-hashtag"
)

func main() {
  text := "An example of a text with a #hashtag #another #Another"
  hashTags := hashtag.NewParser(true).Parse(text)
  fmt.Println(hashTags)

  // Output: ["hashtag": 1, "another": 1, "Another": 1]
}