Im trying to create a function to check for a substring within a string in php.
public static function stringCheck ($string, $substring) {
$patern = "/".$substring."/";
if (preg_match($substring, string) {
return true;
}
else return false;
}
but if i enter a special character used in preg_match (^.[$()|*+?{) it screws up ...
I have a T-SQL stored proc that supplies a good amount of data to a grid on a .NET page....so much so that I put choices at the top of the page for "0-9" and each letter in the alphabet so that when the user clicks the letter I want to filter my results based on results that begin with that first letter. Let's say we're using product na...
Hey, I have an array of strings and I want to replace a certain substring in each of those elements. Is there an easy way to do that besides iterating the array explicitly?
Thanks :-)
...
I have a large set (100k) of short strings (not more than 100 chars) and I need to quickly find all those who have a certain substring.
This will be used as a search box where the user starts typing and the system immediately gives "suggestions" (the strings that have as a substring the text that the user typed). Something similar to th...
What is the difference between
alert("abc".substr(0,2));
and
alert("abc".substring(0,2));
They both seem to output “ab”.
...
I have two strings which must be compared for similarity. The algorithm must be designed to find the maximal similarity. In this instance, the ordering matters, but intervening (or missing) characters do not. Edit distance cannot be used in this case for various reasons.
The situation is basically as follows:
string 1: ABCDEFG
string...
Hello,
I have a large string (an RSS Article to be more precise) and I want to get the word in a specific startIndex and endIndex. String provides the substring method, but only using ints as its parameters. My start and end indexes are of type long.
What is the best way to get the word from a String using start and end indexes of typ...
Here's a screenshot of the twitter app for reference: http://screencast.com/t/YmFmYmI4M
What I want to do is place a floating pop-over on top of a substring in an NSAttributedString that could span multiple lines. NSAttributedString is a requirement for the project.
In the screenshot supplied, you can see that links are background-hig...
Hi all,
I'm trying to implement ellipsis in Umbraco, the requirement being 15 characters of intro text but always ending on a full word.
I thought of using XSLT, but then realised that I can use a simple extension method written in C# instead.
I can easily substring the text and append "..." but am stuck with the issue of having to en...
I was wondering whether there's a better way of doing this; say we read stdin to a string using fgets() where the string includes a total of n integers (e.g. 5 16 2 34 for n = 4), what would be the best way of extracting them? There has got to be a better way than this hack:
for (i=0, j=0; i<n; ++i, j+=pos)
sscanf(string+j, "%d%n",...
I have the following xml.
<root query="Smith Antony Blah Jones">
And the following xsl to split the string into different variables.
<xsl:variable name="query">
<xsl:value-of select="substring-before (root/@query, ' ')" />
</xsl:variable>
<xsl:variable name="query1">
<xsl:value-of select="substring-before(substring-after(root/@que...
I'm attempting to write a basic dna sequencer. In that, given two sequences of the same length, it will output the strings which are the same, with a minimal length of 3.
So input of
abcdef dfeabc
will return
1 abc
I am not sure how to go about solving the problem.
I can compare the two strings, and see if they are completely equal...
Ok, I am trying to get the right three characters of a string in an Android app I'm writing.
Based on the research I've done in the SDK and online I should be able to use something like the following to do it.
millisecondsD = millisecondsD.substring(millisecondsD.length() -3, millisecondsD.length());
However, I get a force close when...
This is a performance based question, not a "I don't understand" or "best practice" question.
I have a varchar field in a SQLServer database that is guaranteed to be longer than 7 chars.
I need to extract a char(4) field consisting of the 2nd, 3rd, 4th and 5th chars in the varchar.
For example if the varchar had the value 1234567890 I ...
Hello all,
I have this C function which attempts to tell me if a sub string is contained in a string.
int sub_string(char parent [1000], char child [1000]){
int i;
i = 0;
int parent_size = (int) strlen(parent);
int child_size = (int) strlen(child);
char tempvar [child_size];
int res;
res = 1;
while(i<(parent_size - ...
I've got a SharePoint problem which I need some help with. I'm creating some custom ItemStyles to format the output of a Content Query Webpart (CQWP) but I need to insert a "view all" button into the output.
View all needs to point to:
http://www.site.com/subsite/doclibrary1/Forms/AllItems.aspx
All the individual files in the document ...
I'm getting an ArgumentOutOfRange error when using substring function in .NET. I'm new to .NET so probably doing something wrong. I have a txtField, which is a text field component in GUI. I'm using Microsoft Visual Basic 2010 Express
txtField.Substring(txtField.Length-4,txtField.Length-1)
If txt.Field contains only numberic values...
I'd like to find the longest repeating string within a string, implemented in JavaScript and using a regular-expression based approach.
I have an PHP implementation that, when directly ported to JavaScript, doesn't work.
The PHP implementation is taken from an answer to the question "Find longest repeating strings?":
preg_match_all('/...
Hello there,
I have an array and in that array I have an array key that looks like, show_me_160 this array key may change a little, so sometimes the page may load and the array key maybe show_me_120, I want to now is possible to just string match the array key up until the last _ so that I can check what the value is after the last und...
Instruments leaks says that this code leaks:
NSString *name = [file substringToIndex:i];
Layer *actualLayer = nil;
for (Layer *lay in layers) {
if ([lay.layerName isEqual:name]) {
actualLayer = lay;
}
}
name is the leaking object. There are some strange things: it only leaks sometimes, not always (this snippet of code ...