Questions tagged [string-search]

String searching algorithms (also known as string matching algorithms) are an important class of string algorithms that try to find a place where one or several strings (also called patterns) are found within a larger string or text.

String searching algorithms (also known as string matching algorithms) are an important class of string algorithms that try to find a place where one or several strings (also called patterns) are found within a larger string or text.

Use this tag for programming questions related to string searching algorithms.

Source: Wikipedia

261 questions
2
votes
1 answer

Check if substring of a string exists in datatable

I have a DataTable like this: column1 column2 ----------- ---------- 1 abc d Alpha 2 ab Gamma 3 abc de Harry 4 xyz Peter I want to check if a substring of a string exists in the datatable. e.g. If the string I am…
Scorpion
  • 23
  • 4
2
votes
1 answer

string search across multiple buffers algorithm

I'm developing a NGINX module and need to do a complex string replacement in the response body on the fly without a cumulative buffer (See the below ngx_http_output_body_filter_by_me). Sometime, the buffer in chain cannot hold all response like…
samm
  • 620
  • 10
  • 22
2
votes
1 answer

C++ strange results - brute force is quicker than Rabin-Karp...?

Currently working on a string search program for a uni module, and I've managed to implement the algorithms successfully, at least to the point where they're finding the string consistently. I implemented Boyer Moore and Rabin Karp. I also threw in…
2
votes
0 answers

How could you remove the similar portion from two large strings?

I am working on classification of some documents and a number of the documents have large sections of similar (and usually irrelevant) text. I would like to identify and remove those similar sections, as I believe I may be able to make a better…
Kern Hast
  • 21
  • 2
2
votes
0 answers

Search for a sub-string in any position in a given array of strings using Trie

I have an array of n strings. I want to select all the elements of the array that contains the given string. For example input = "ra" array = ["abas", "aras", "as", "ask", "asi", "aso", "atras", "ram" ] output = ["aras", "atras", "ram"] My solution…
Rami Chasygov
  • 2,714
  • 7
  • 25
  • 37
2
votes
1 answer

Can C++ program string search as fast as and/or faster than python?

I'm not sure why I'm having easier time string searching in program I wrote in python faster than a program I wrote in C++. Is there a trick I'm missing? Generating Use Case This is for a single line use case, however in the real use case I care…
Iancovici
  • 5,574
  • 7
  • 39
  • 57
2
votes
0 answers

Multiple-String Search Efficiency for Partial Matches

I'm building a decoder for a very non-compliant binary file and I need to search the binary file (specifically, a partial byte buffer, probably going to choose 4kB) for frame headers. This means using an efficient multiple-pattern string search…
user19087
  • 1,899
  • 1
  • 16
  • 21
2
votes
1 answer

Does KMP algorithm perform less comparisons than the simplified Boyer-Moore algorithm?

Does the KMP (Knuth–Morris–Pratt) algorithm perform fewer comparisons than the simplified Boyer-Moore algorithm?
fmunshi
  • 415
  • 2
  • 8
  • 15
2
votes
2 answers

String Finding Alg w/ Lowest Freq Char

I have 3 text files. One with a set of text to be searched through (ex. ABCDEAABBCCDDAABC) One contains a number of patterns to search for in the text (ex. AB, EA, CC) And the last containing the frequency of each character (ex. A 4 B 4 C 4 D…
Racehorse35
  • 121
  • 10
2
votes
1 answer

Why does the two way algorithm match the left part in reverse?

The Two Way algorithm is a substring search algorithm (primary paper, 1.4 MB PDF). It splits the search pattern x in two parts: x = xl xr, and first it tries to match xr against the text, and if that is successful the algorithm prescribes matching…
bluss
  • 12,472
  • 1
  • 49
  • 48
2
votes
2 answers

Way to implementing Search functinality on a Window

I am working on a (WPF + C#) application. I have to implement search functionality. It will allow to search all the occurrences of a particular string on the specific part of Window. What can be the best way to do this?
viky
  • 17,275
  • 13
  • 71
  • 90
2
votes
3 answers

Partial string search in boost::multi_index_container

I have a struct to store info about persons and multi_index_contaider to store such objects. Mult-index uses for search by different criteria. I've added several persons into container and want to find person by lastname. It works great, if I use…
Titan
  • 65
  • 1
  • 6
2
votes
1 answer

String searching algorithm for Chinese characters

There is Python code available for normal string searching algorithms, such as Boyer-Moore. I am looking to use this on Chinese characters, but it doesn't seem like the same implementation would work. What would I do in order to make the algorithm…
Jack Low
  • 51
  • 1
  • 3
2
votes
2 answers

Getting phrases which have each word starting with an uppercase character

Currently i have tried getting words that start with an upper case in a sentence using Character.isUpperCase. However now i would like to only retrieve phrases in a sentence where all the 1st letter in every word of the phrase is upper case. How…
user2541163
  • 717
  • 2
  • 7
  • 22
2
votes
2 answers

Fuzzy substring search from a list of strings

Okay, I've seen lots of posts about fuzzy string matching, Levenstein distance, longest common substring, and so on. None of them seem to fit exactly for what I want to do. I'm pulling product results from a variety of web services, and from those I…
samson
  • 1,152
  • 11
  • 23