Effective string searching algorithm (Aho-Corasick).
Add repository and dependency to build.gradle file:
... repositories { ... maven { url = "https://maven.pkg.github.com/vanam/string-search" credentials { username = project.findProperty("gpr.user") password = project.findProperty("gpr.key") } } } dependencies { ... implementation 'com.martinvana:string-search:1.0.0' } ...Read about Github Tokens, generate one, and update your global gradle.properties file located in a project root directory or GRADLE_USER_HOME environment variable.
gpr.user=GITHUB_USERNAME gpr.key=GITHUB_TOKENFor more information visit Configuring Gradle for use with GitHub Packages
// Init algorithm with patterns StringSearch stringSearch = new StringSearch("foo", "bar"); // Search for patterns in text Hits hits = stringSearch.search("foo bar in a long text"); // Were matches found? hits.isEmpty(); // How many matches were found? hits.size(); // What was found? Map<String, SortedSet<Integer>> pattern2positionsInTextMap = hits.hits();