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

Compare first word of each line of a file to a variable in php

I've just started php and I can't find an easy way to compare to a variable each first word of a line of a text file in a format("userid firstname lastname password").
Ryan
  • 29
  • 1
  • 8
-1
votes
3 answers

Find out the maximum number of decimal places within a string of numbers

The string looks like this like something along the lines of 3*2.2or 6+3.1*3.21 or (1+2)*3,1+(1.22+3) or 0.1+1+2.2423+2.1 it can vary a bit. I have to find the amount of decimal places in the number inside the string with the most decimal places. Im…
Sofia
  • 147
  • 7
-1
votes
1 answer

How do I parse a string for key value pairs with no delimiters?

How do I parse a string in C# to extract key-value pairs without any delimiters between key and value? I have a string that looks like this string str = "\nFIRSTNAMEJOHN\nLASTNAMESMITH\nADDRESS1590 GRACE STREET\nBIRTHDATE04201969" After splitting…
zjc2653
  • 1
  • 2
-1
votes
1 answer

How are BSTs deployed as dictionaries for string search?

link:https://www8.cs.umu.se/kurser/TDBAfl/VT06/algorithms/BOOK/BOOK/NODE39.HTM In the following problem the author discusses using BST as dictionary for length-k substrings. Can anyone explain how he does so in the problems context.
rajat008
  • 23
  • 4
-1
votes
1 answer

How to mitigate server-dependent behavior for REQUEST_URI to use it to suppress a specific shortcode

I noticed something quirky regarding when I put the following line in my PHP code: echo strpos($_SERVER['REQUEST_URI'], "/?s="); If the following URL is entered: https://s1.temporary-access.com/~allacros/devel/?s=tahiti the echo statement returns…
-1
votes
1 answer

Reverse Factor Algorithm

I'm a newbie. I've been learning about algorithms for two months now. I'm generally doing okay but I'm not good at understanding search algorithms nor implementing them. I'm particularly stuck on this pattern search algorithm, Reverse Factor. I've…
Ellie Doe
  • 3
  • 2
-1
votes
1 answer

Most effective code to search character in string

Let's say we have a given string of chars DataString DB 'AGIJKSZ', 0FFH ; What would be the most time-effective procedure to find let's say J in it? By time-effective I mean least amount of clock ticks. It's a x86 processor with these instruction…
Jarek N
  • 55
  • 9
-1
votes
1 answer

Python Script to Search String in all file contents and also in subfolder

import os from fnmatch import fnmatch root = 'Directory' for path, subdirs, file in os.walk(root): for files in file : with open(files) as f: contents = f.read() if 'Search_string' in contents: print os.path.join(path, files) It is…
Atul D
  • 31
  • 6
-1
votes
1 answer

Batch script to kill process if string is found in text file

I have a process that writes logs to a acc.txt file and I'm trying to restart the process when a certain string has been found inside of that .txt file. Once the string is found and matches with what I'm looking for, the acc.txt contents should be…
Chris
  • 41
  • 2
  • 10
-1
votes
2 answers

How to search a string with space within another string in objective-C?

I wanted to search for a string: @"Data " (including the space at the end) in the string (NSString *info). What should I do? The string that is being searched has a space. Instead of @'data', I'm trying to find @'data '.
-1
votes
1 answer

find multiple needles in haystack - String Searching

Question: How to find the existence of strings within a body of content from a document with sub-linear performance and where the string to be found must be done so in order or their associated id not alphabetical order. Preferably we would solve…
Orcra
  • 132
  • 9
-1
votes
1 answer

windows scripting to search a value in '.HL7' file

Through windows batch file, I am trying to - a. open a folder > open latest '.hl7. file (by date) in the folder. b. search a specific value in the file. e.g value of the key 'name' c. echo the value. I am new to scripting, Can anybody help me write…
AmitGupta
  • 43
  • 1
  • 6
-1
votes
3 answers

Skipping specific number of words in a string using Regex

I have a string "pqr hello world merger was to be undertaken between xyz as the sole acquirer but got delayed" I want to make sure that "delayed" always comes after 5 words or more following "merger" . How can this be achieved using regex and…
Anirudh C
  • 39
  • 5
-1
votes
1 answer

Speed up an implementation of Boyer-Moore-Horspool string search

I have a bit of trouble implementing the BMH algorithm in C++. Here's the code: #define Nm 2000005 int D[256]; char To[Nm],P[Nm],*T; int Tl,Pl; int cont; void initialize_Lenght() { Tl=strlen(To); Pl=strlen(P); T=To; } void compute_D() { …
-2
votes
1 answer

Writing a simple function which returns True if there is a duplicate character present

So basically as in the title. Here is what I am trying to do: 3 24 function RepeatedChar (l: char; s: string): boolean; 25 var 26 c, ordl, ords: integer; {counter} 27 begin 28 c := 0; 29 writeln(' LAUNCHED SEARCH FOR DUPLICATES '); …
Rookie
  • 3
  • 1
1 2 3
17
18