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
2 answers

Searching in a string a substring

I have a string (Str) with phrases separated by a character (let's define it as "%" for simple understanding). I want to search for phrases in this string (Str) that contains a word (like "dog") and put that phrase in a new string I was wondering…
Monick
  • 11
  • 2
0
votes
1 answer

VBA String Search for Contains a Number

I'm doing a data quality check on a large column of strings (ie. Last Name) and want to see if they contain a number. The VBA code that I've tried so far should be straight forward: if the LastName field contains 1 or 2 (etc.) than the ReasonCode =…
Marshall Gu
  • 137
  • 3
  • 14
0
votes
1 answer

Find a string that contains a cross reference in Word VBA

The objective on my code is to be able to search for a set of key terms using VBA in order to be able to apply a bold formatting. I am trying to set the code to expect strings of the following formats: Item # Item #@ Item #@@ Item ## Item…
OAR617
  • 79
  • 9
0
votes
2 answers

How to run a string search algorithm through whole body of text

I am using the brute force string search algorithm to search through a small sentence, however I want the algorithm to return every time it finds the certain string instead of finding it once and then stopping //Declare and initialise…
Brady Harper
  • 235
  • 1
  • 3
  • 17
0
votes
1 answer

How to check each time-series entry if name/id is in previous years entries?

I'm stuck. I have a dataframe where rows are created at the time a customer quotes cost of a product. My (truncated) data: import pandas as pd d = {'Quote Date': pd.to_datetime(['3/10/2016', '3/10/2016', '3/10/2016', …
0
votes
1 answer

What if the 'needle' parameter of strpos() function contains a converted integer value that can not be applied as the ordinal value of any character?

I'm using PHP 7.2.8 on my machine running on Windows 10 Operating System. I come across the following text from the description of 'needle' parameter in strpos() function given in the PHP Manual : needle If needle is not a string, it is converted…
PHPLover
  • 1
  • 51
  • 158
  • 311
0
votes
1 answer

using pandas with python to write to a dataframe

import pandas as pd import re import numpy as np data= [['Empty','CMI-General Liability | 05-9362','Empty','Empty'],['Empty','Central Operations','Empty','Empty'],['Empty','Alarm Central 05-8642','Empty','Empty'],['Empty','Market…
Royale_w_cheese
  • 297
  • 2
  • 9
0
votes
0 answers

Fast search for strings in tidy corpus R

I have a tidy dataframe created from a text corpus. I want to create a new binary variable based on the presence of a string from a vector of strings in the tidy corpus texts. My current for loop works, but is much too slow with 600k observations,…
Garglesoap
  • 565
  • 6
  • 18
0
votes
1 answer

Efficient way to find all instances of Substring within a Swift String

Swift 4 apparently has introduced a lot of new changes to String. I'm wondering if there is now a built-in method for finding all instances of a substring within a String. Here's the kind of thing I'm looking for: let searchSentence = "hello world,…
Adam Bryant
  • 545
  • 3
  • 13
0
votes
3 answers

Searching for substrings using 'srtchr()'

Using the function strchr is it possible to search for a substring in a string instead of a character? Example: Instead of this : int r=strchr("Hello World",'W'); Can this be used : int r=strchr("Hello World","World");
Nnn
  • 191
  • 3
  • 9
0
votes
0 answers

Rabin-Karp constant-time substring hash lookup

Given a string S[0..N-1], I want to be able to get the hash of any of its substrings S[i..j] in O(1) time, with O(N) preprocessing. Here's what I have so far (in Python): BASE = 31 word = "abcxxabc" N = len(word) powers = [] prefix_hashes = [] b…
shooqie
  • 950
  • 7
  • 17
0
votes
1 answer

How can I find a string in a cell containing a link?

I have some cells in openoffice calc which contain links/URLs. They display, of course, in calc as text, and hovering the mouse shows the URL. Clicking on those cells brings up the URL referenced. I want to match a string in the displayed text. The…
0
votes
2 answers

php strpos and approximate match with 1 character difference

I searched the system but couldn't find any help I could understand on this, so here goes... I need to find an approximate match for a string in php. Essentially I'm checking that all the $names are in the $cv string and if not it sets a flag to…
arathra
  • 155
  • 1
  • 11
0
votes
1 answer

Improve performance when searching for a string within multiple word files

I have drafted a PowerShell script that searches for a string among a large number of Word files. The script is working fine, but I have around 1 GB of data to search through and it is taking around 15 minutes. Can anyone suggest any modifications I…
0
votes
1 answer

String search and replace Java

I am dealing with an algorithm approach to finding keywords into my string. I have a HashSet contains almost 1 million keys in it and I want to replace all of these keys with blank into my sentences. My problem is this, when i have 1000 sentences…
Abdullah Tellioglu
  • 1,434
  • 1
  • 10
  • 26