|
What is the fastest way to compare a string with an array of strings in C#2.0
Started by Greens on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
Will return a boolean exists = Array.IndexOf(array, input) >= 0;
You mean to see if the string is in the array? I can't remember if arrays support....
Array to the list via AddRange(), then call list.Contains({string to compare}).
|
|
I've got a program written in c# where there are a lot of comparisons between ints and strings.
So for performance reasons I would just like to know which is more efficient?
If we have:
int a = 5; string b = "5"; if(a == int.Parse(b)) { } OR if(a.ToString...
Started by The_Butcher on
, 11 posts
by 11 people.
Answer Snippets (Read the full thread at stackoverflow):
Also....
Parsing a String:
System.Diagnostics.Stopwatch sw=new System.Diagnostics.Stopwatch(); int a = 5; string b = "5 to really worry about.
string are compared by the length and number at once.
Trying to compare.
|
|
I would like to compare two strings and get some score how much these look alike. For example "The sentence is almost similar" and "The sentence is similar" .
I'm not familiar with existing methods in Java ME, but for php I know the levenshtein function...
Started by hsmit on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
I found.
Wikipedia has some more algorithms that measure similarity of strings.
Or, more precisely, how many class library.
Well, the Levensthein distance is a measure for how similar strings are.
|
Ask your Facebook Friends
|
I need to compare strings in shell:
var1="mtu eth0" if [ "$var1" == "mtu *" ] then # do something fi
But obviously the "*" doesn't work in Shell. Is there a way to do it?
Started by n-alexander on
, 9 posts
by 9 people.
Answer Snippets (Read the full thread at stackoverflow):
If [ "$(echo $var1 | cut -c 4)" -eq "mtu can call expr to match strings against regular expressions from within Bourne Shell scripts anything if [ "${var1#mtu }" != "$var1" ] ; then....
The program "cut" will happily shorten a string.
Tools.
|
|
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.
Started by tuckster on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
Cmp Compare
'a' cmp 'b' # -1 'b' cmp 'a' # 1 'a' cmp 'a' # 0
eq Equal to
'a' eq 'b' # 0 'b' eq to Sinan Ünür comprehensive listing of....
Matched!\n" if ($str1 eq $str2)
Perl has seperate string comparison and numeric comparison operators.
|
|
I have two strings read in from textfiles to compare and when I try to compare these files with winmerge or pspad, they both show as the same text strings. If I compare them with the following function, it fails:
string string1 = File.ReadAllText(@"c:...
Started by Carra on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
You could convert them both to byte[] using the methods under System.Text.Encoding and then compare
Well, you don't have the .NET strings in WinMerge or pspad, so something could well be going wrong.
|
|
I created one Java program to compare two strings:
String s1 = "Hello"; String s2 = "hello"; if (s1.equals(s2)) { System.out.println("hai"); } else { System.out.println("welcome"); }
It displays "welcome". I understand it is case sensitive. But My problem...
Answer Snippets (Read the full thread at stackoverflow):
Use equalsIgnoreCase
More about string can be found in String Class and String Tutorials.
|
|
I get two strings formated like (Brazilian Format): "DD/MM/YYYY", I need to compare both. Since the first field is the begin and the last is the end,
My validation is begin <= end
Date.new(begin) is generating 'invalid date' even on ISO !
Started by Fabiano PS on
, 6 posts
by 6 people.
Answer Snippets (Read the full thread at stackoverflow):
If you're handed a date string, then you can use fuzzy lollipop's method....
Because of the format of your date string, I would recommend'), 10); var start = new Date(startYear, startMonth, startDay);
etc.
Use new Date().
Don't use Date.new.
|
|
I've been using the " == " operator in my program to compare all my strings so far. However, I ran into a bug, changed one of them into .equals() instead, and it fixed the bug.
Is " == " bad? When should it and should it not be used? What's the difference...
Started by nute on
, 12 posts
by 12 people.
Answer Snippets (Read the full thread at stackoverflow):
// These two";
But beware of nulls!
"==" handles null strings fine, but calling ".equals" from a null string will cause compares....
== is for testing weather two strings are the same object .
Object eg: String interning ).
|
|
Hi,
I wonder if there is an easy way to check if two strings match by excluding certain characters in the strings. See example below.
I can easily write such a method by writing a regular expression to find the "wild card" characters, and replace them...
Started by Mystic on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
The DLD between "ABC-EFG" and "ABC*EFG" is 1—"the minimum number of operations needed to transform one string for the two strings "ZBC-EFG" and....
Levenshtein distance is one of several algorithms dealing with fuzzy string searching .
|