substring

Fast filtering of a string collection by substring?

Do you know of a method for quickly filtering a list of strings to obtain the subset that contain a specified string? The obvious implementation is to just iterate through the list, checking each string for whether it contains the search string. Is there a way to index the string list so that the search can be done faster? ...

javascript substring help.

I have a string "2500 - SomeValue". How can I remove everything before the 'S' in 'SomeValue'? var x = "2500 - SomeValue"; var y = x.substring(x.lastIndexOf(" - "), // this is where I'm stuck, I need the rest of the string starting from here. Thanks for any help. ~ck ...

Longest Non-Overlapping Substring

I wonder if anyone knows the (optimal?) algorithm for longest recurring non-overlapping sub string. For example, in the string ABADZEDGBADEZ the longest recurring would be "BAD". Incidentally if there is no such result, the algorithm should alert that such a thing has occurred. My guess is that this involves suffix trees. I'm sure th...

Substring algorithm

Can someone explain to me how to solve the substring problem iteratively? The problem: given two strings S=S1S2S3…Sn and T=T1T2T3…Tm, with m is less than or equal to n, determine if T is a substring of S. ...

substring extract C# problem

hi .... i have a text like this .... ======== 1079.tif Image Description : Vexcel-UCD-Level-3 ------------------ CAM_ID: UCD-SU-1-0018 [5] RECORD_GUID: 64763E99-3573-43AD-995B-8A07E3FE2BE3 IMG_NO: 1079 CAPTURE_TIME: 2004/03/15 02:07:17.641 IMG_TYPE: H...

Search Hex substring in string

Hi all! Well i got a socket that receives binary data and I got that data into an string, containing values and strings values too. (for example "0x04,h,o,m,e,....") How can i search for an hex substring into that string? I.e. i want to search "0x02,0x00,0x01,0x04". I'm asking for a c++ version of python 'fooString.find("\x02\x00\x01...

Exctract 2 words from a string

Hey, im working with a receipt layout and trying to divide up a products descriptiontext into 2 lines if its longer then 24 characters. my first solution was something like this: If Row.Description.Length >= 24 Then TextToPrint &= Row.Description.Substring(0, 24) & " $100" TextToPrint &= Row.Description.Substring(24) & vbNewLine e...

How to extract words from a sentence efficiently in C?

I need an efficient function that extracts first second and rest of the sentence into three variables. ...

String index out of bounds? (Java, substring loop)

This program I'm making for a COSC course isn't compiling right, I keep getting the error: Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 2 at java.lang.String.substring(String.java:1765) at VowelCount.main(VowelCount.java:13) Here's my code: import java.util.Scanner; public class V...

l-value substr method in C++

I want to create a substr method in C++ in a string class that I made. The string class is based on C-style string of course, and I take care of the memory management. I want to write a substr(start, length) function that can work on the regular way: CustomString mystring = "Hello"; cout << mystring.substr(0,2); // will print "He" ...

Most prevalent substring of length X

Hi! I have a string s and I want to search the most prevalent substring of length X in s, overlap are admited. For example: s="aoaoa" and X=3, return "aoa" (which appear 2 times in s). Is it an algorithm that founds this substring in O(n)? ...

Mysql group by substring

I have a table with the following structure: id bigNumber text 1 1200321030011010233 "an item with some text" 2 1200321030011014563 "another item with some more text" 3 3120323434432211133 "more...." ... ... The table contains approximately 50.000 records. I want to do the following query but it is slow: SELECT COUNT(*), ...

How to allow spaces in string when searching for position of substring in C?

I'm stuck on part of my homework, I had to find the rightmost occurrence of a substring inside of a string. I have the first part done (can find substring in single word strings), but now I am having trouble with the second part. I have to use a modified version of getline in order to allow multi-word strings (aka with spaces). Here's...

charAt() or substring? Which is faster?

I want to go through each character in a String and pass each character of the String as a String to another function. String s = "abcdefg"; for(int i = 0; i < s.length(); i++){ newFunction(s.substring(i, i+1));} or String s = "abcdefg"; for(int i = 0; i < s.length(); i++){ newFunction(Character.toString(s.charAt(i)));} Th...

How to get a part of String using shell script?

I have a requirement in a shell script. I get this location information from a text file; it is always valid. /opt/sasuapps/senny/publish/gbl/SANDHYA/drop1 I need to check if the directory is empty or not which I have done. If the directory is not empty, I need to delete the files and directory under that location. As a part of sec...

AppleScript: Index of substring in string

I want to create a function that returns a substring of a specific string from the beginning of said string up to but not including the start of another specific string. Ideas? So something like: substrUpTo(theStr, subStr) so if I inputted substrUpTo("Today is my birthday", "my"), it would return a substring of the first argument u...

C#: Extract only right most n letters from a string

How can I extract a substring which is composed of the rightmost six letters from another string? Ex: my string is "PER 343573". Now I want to extract only "343573". How can I do this? ...

jquery - substring to truncate text?

I'm trying to figure out how to truncate the first paragraph, and I've tried: $div.children( ('p:eq(0)').substring(0,100)); $div.children( ('p:eq(0)'.substring(0,100))); But neither have worked... Here's the complete code (which someone here helped me with!) $j('#hp-featured-item > div[id^="post-"]').each(function() { va...

Drawing in NStextField

Hey ho! If you wanted to implement a highlighting for specific substrings in a NSTextField like on the screenshot (Tweetie.app) how would you do it? :) Thanks for your help! ...

Bash script on Solaris, using ":" on an array does not always work

I have a strange issue with array manipulation within a bash script on Solaris. I am using the syntax ${varName[@]:index} to obtain all of the elements in array varname after the specified index. However, if there is only one element after the specified index, nothing is returned. This can be easily demonstrated by example: #!/bin/bash...