Which is faster? This:
bool isEqual = (MyObject1 is MyObject2)
Or this:
bool isEqual = ("blah" == "blah1")
It would be helpful to figure out which one is faster. Obviously, if you apply .ToUpper() to each side of the string comparison like programmers often do, that would require reallocating memory which affects performance. But h...
When comparing two strings in c# for equality, what is the difference between InvariantCulture and Oridinal comparision.
...
Hi, anyones knows how to do this?
Edit: I am trying to do >=. I correct the Title.
...
I really don't know why the if statement below is not executing:
if (s == "/quit")
{
System.out.println("quitted");
}
Below is the whole class.
It is probably a really stupid logic problem but I have been pulling my hair out over here not being able to figure this out.
Thanks for looking :)
class TextParser extends Thread {
...
I'm looking for a Python module that can do simple fuzzy string comparisons. Specifically, I'd like a percentage of how similar the strings are. I know this is potentially subjective so I was hoping to find a library that can do positional comparisons as well as longest similar string matches, among other things.
Basically, I'm hoping...
What, if anything, is the benefit of using
If StrComp(strVal1, strVal2, vbTextCompare) = 0 Then
as opposed to using
If strVal1 = strVal2 Then
If Option Compare Text is set at the module level, is there any difference?
I know StrComp handles null scenarios and <> scenarios, I am only interested in the situation where strVal1 and st...
I have a line of code that is cause a "EXC_BAD_ACCESS" error. The line of code is as follows (formatted into one line and nested code removed for ease of reading).
if (![sendData isEqualToString:@"-"]){ ... }
The actual error occurs on the IF line. the odd thing is that if I put a breakpoint on that line, the NSString called sendData ...
There are a number of ways to compare strings. Are there performance gains by doing one way over another?
I've always opted to compare strings like so:
string name = "Bob Wazowski";
if (name.CompareTo("Jill Yearsley") == 0) {
// whatever...
}
But I find few people doing this, and if anything, I see more people just doing a straig...
In answering this code golf question, I ran across a problem in my answer.
I've been testing this and I cannot even get these two comparisons to work in the code, despite the fact that IRB has the right behavior. I really need some help here.
Here's the code, below that will be an explanation of the problem.
def solve_expression(expr...
I want to compare several strings to each other, and find the ones that are the most similar. I was wondering if there is any library, method or best practice that would return me which strings are more similar to other strings. For example:
"The quick fox jumped" -> "The fox jumped"
"The quick fox jumped" -> "The fox"
This compa...
When using the String.Equals(string a, string b, StringComparison comparisonType) and not caring about the case of 'a' and 'b', what's the proper StringComparison to use?
In other words, what's the difference between StringComparison.CurrentCultureIgnoreCase, StringComparison.InvariantCultureIgnoreCase, and StringComparison.OrdinalIgnor...
How do I compare two strings in Perl?
I am learning Perl, I had this basic question looked it up here on StackOverflow and found no good answer so I thought I would ask.
...
I'm attempting to compare two strings with is. One string is returned by a function, and the other is just declared in the comparison. is tests for object identity, but according to this page, it also works with two identical strings because of Python's memory optimization. But, the following doesn't work:
def uSplit(ustring):
#...
I know that for instance, using:
if (in_array('...'), array('.', '..', '...') === true)
Over:
if (in_array('...'), array('.', '..', '...') == true)
Can increase performance and avoid some common mistakes (such as 1 == true), however I'm wondering if there is a reason to use strict comparisons on strings, such as:
if ('...' === '.....
I'm trying to compare a character array against a string like so:
const char *var1 = " ";
var1 = getenv("myEnvVar");
if(var1 == "dev")
{
// do stuff
}
This if statement never validates as true... when I output var1 it is "dev", I was thinking maybe it has something to do with a null terminated string, but the strlen of "dev" and v...
Here's the problem -- I have a few thousand small text snippets, anywhere from a few words to a few sentences - the largest snippet is about 2k on disk. I want to be able to compare each to each, and calculate a relatedness factor so that I can show users related information.
What are some good ways to do this? Are there known algorit...
I've recently started using Mercurial and when I reverted one of my .SQL files, Mercurial performed a binary comparison. This obviously limits the visibility of the changes that were made, as there is no diff.
Is there an option to set file types to do a string compare?
I'm using Tortioise Hg 0.8.1 with Mercurial 1.3.1.
...
For sorting item names, I want to support numbers correctly. i.e. this:
1 Hamlet
2 Ophelia
...
10 Laertes
instead of
1 Hamlet
10 Laertes
2 Ophelia
...
Does anyone know of a comparison functor that already supports that?
(i.e. a predicate that can be passed to std::sort)
I basically have two patterns to support: Leading number (as...
The data string is receive through a socket connexion. When receiving the first example where action variable would = 'IDENTIFY', it works. But when receiving the second example where action variable would = 'MSG' it does not compare.
And the most bizarre thing, when I use Telnet instead of my socket client both are being compare succe...
I have an Cocoa app that calls a web service. When I parse the response from the web service I am getting a \n as the last character in my foundCharacters delegate for the NSXMLParser for each element in the XML.
When I try to do the following:
if (![string isEqualToString:@"\n"])
The check will always fails to catch the newline. ...