Skip to content

Latest commit

 

History

History
60 lines (44 loc) · 1.42 KB

README.adoc

File metadata and controls

60 lines (44 loc) · 1.42 KB

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]
}