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
0
votes
1 answer

What is the most efficient way to find the particular strings on huge text files (>1GB) in python?

I am developing a string filter for huge process log file in distributed system. These log files are >1GB and contains millions of lines.These logs contains special type of message blocks which are starting from "SMsg{" and end from "}". My program…
0
votes
2 answers

How to avoid adding file names in 'findstr' results?

I am using findstr to search an string in some file and redirecting the search result to another txt file but need to omit the searched file name added in results. My batch file has :- findstr /s "TEST" subfolder/test.dat > output.txt and the result…
Yash
  • 173
  • 2
  • 13
0
votes
1 answer

In string search for number to determine next in sequence?

I have a list of build numbers (e.g. R1079-AAA-001, ...-002 etc.) in which the value of "R1079" changes depending on the machine being used. What I want to do is search through the list to determine the last used build number (the last 3 digits) in…
0
votes
1 answer

Is there a good way to find exact matches of a extremely long string ~500 characters from a couple megabyte sized CSV file?

I'm trying to find a match of a ~500 character long DNA sequence from a few megabyte large CSV file containing different sequences. Before each sequence in the CSV file, there is some metadata I would like to have. Each sequence and sequence…
riv
  • 119
  • 1
  • 1
  • 9
0
votes
1 answer

Optimizing a lot of Scanner.findWithinHorizon(pattern, 0) calls

I'm building a process which extracts data from 6 csv-style files and two poorly laid out .txt reports and builds output CSVs, and I'm fully aware that there's going to be some overhead searching through all that whitespace thousands of times, but I…
user244343
0
votes
3 answers

Is there a hashing function that can be used in finding similar (not necessarily equal) strings?

What I need is a hashing function that operates on fixed data sizes, obviously for non security purposes. It needs to map similar strings to similar or equal hashes, in other words small changes in strings should make no or really small changes to…
mewais
  • 1,265
  • 3
  • 25
  • 42
0
votes
1 answer

During string search using window.find() a dialog box appear

I am trying to search string and highlight those string. But during search a find dialog box appear. How can I disable the find dialog box ? Here is my code --> function doSearch(text) { if (window.find && window.getSelection) { …
0
votes
1 answer

a table of occurances of pattern in an SQL table field

I have this table text | txt_id | txt_content | |--------+----------------------------------------------| | 1 | A ton of text and <> | | 2 | More text <> that …
fakedrake
  • 6,528
  • 8
  • 41
  • 64
0
votes
0 answers

How to check if one of the words in an NSString starts with a certain string?

Given the string This is just an example string to show what I mean. How do I check that none of the words in this string start with amp, or that one (or more) of the words start with s? This is what the iOS contacts app does when searching in the…
meaning-matters
  • 21,929
  • 10
  • 82
  • 142
0
votes
1 answer

C# Regex find string between two different pairs of strings

Using C# RegEx, I am trying to find text enclosed by two distinct pairs of words, say, start1....end1, and start2...end2. In my example below I would like to get: text1, text2, text11, text22. string str = "This start1 text1 end1. And start2 text2…
nam
  • 21,967
  • 37
  • 158
  • 332
0
votes
4 answers

how to compare only selected strings in a text with given input in objective-c

i know that the question sounds wears.I couldn't find a better way to put it so i will take my time to explain the question i m struggling with. I have an iPhone app that takes input from user.And i got a plist ( i will convert it to a online…
user3570579
  • 65
  • 1
  • 8
0
votes
3 answers

How can I search a string for each character in Java

I want to find a character within a string. If the character is found, add one to char_counter. How can I implement this? Example: int char_counter = 0; String password = "1234"; String search = "1234"; for(int i = 0; i < password.length() - 1; i++)…
0
votes
0 answers

searching tcp payload for a string occurrence

i am writing a code to search tcp payload of every packet in a libpcap file, to search for a string. so what i am trying to do is, pcap_handle_in = pcap_open_offline(infile, pcap_errbuf); . . . while (pcap_next_ex(pcap_handle_in,…
0
votes
2 answers

Check whether a string contains any member of the arrayList

This is a portion of the string 471 pfm9254-disk01_01 0 io_grp0 online 3 Chassis2_IBMi 100.00GB striped 0 fcmap0 60050768028080EF6400000000001391 1 …
The_Lost_Avatar
  • 992
  • 5
  • 15
  • 35
0
votes
1 answer

How to match the word exactly with regex?

I might be asking this question incorrectly but what I would like to do is the following: Given a large String which could be many 100s of lines long match and replace a word exactly and make sure it does not replace and match any part of any other…
binarycreations
  • 3,091
  • 6
  • 32
  • 38