strsearch

package module
v0.0.0-...-3662280 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 23, 2015 License: MIT Imports: 0 Imported by: 0

README

strsearch

Use Boyer Moore Horspool algorithm to search for a pattern in a text

Golang already has a Contains method on the strings package. However, that uses the Rabin-Karp algorithm.
This library uses the Boyer Moore Horspool algorithm.

To use this library, import as:

import "github.com/callmekatootie/strsearch"

Examples

strsearch.Find(<text>, <pattern>)
strsearch.Find("Hello World!", "orl") // 7

Returns the position of the pattern in the text - position is 0 based

strsearch.Find("What sorcery is this?", "nothing") // -1

Returns -1 if the pattern can't be found in the text

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Find

func Find(text, pattern string) int

Public function that takes in the text and the pattern to find in that text Returns -1 if pattern can't be found, else returns the location (zero based) where pattern can be found Uses Boyer Moore Horspool algorithm

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL