Compare string similarity

static class LevenshteinDistance { public static int Compute(string s, string t) { if (string.IsNullOrEmpty(s)) { if (string.IsNullOrEmpty(t)) return 0; return t.Length; } if (string.IsNullOrEmpty(t)) { return s.Length; } int n = s.Length; int m = t.Length; int[,] d = new int[n + 1, m + 1]; // initialize the top and right of the table … Read more

Comparing strings with tolerance

You could use the Levenshtein Distance algorithm. “The Levenshtein distance between two strings is defined as the minimum number of edits needed to transform one string into the other, with the allowable edit operations being insertion, deletion, or substitution of a single character.” – Wikipedia.com This one is from dotnetperls.com: using System; /// <summary> /// … Read more

PostgreSQL: Case insensitive string comparison

select * where email ilike ‘me@example.com’ ilike is similar to like but case insensitive. For escape character use replace() where email ilike replace(replace(replace($1, ‘~’, ‘~~’), ‘%’, ‘~%’), ‘_’, ‘~_’) escape ‘~’ or you could create a function to escape text; for array of text use where email ilike any(array[‘adamB@a.com’, ‘eveA@b.com’])

What are some algorithms for comparing how similar two strings are?

What you’re looking for are called String Metric algorithms. There a significant number of them, many with similar characteristics. Among the more popular: Levenshtein Distance : The minimum number of single-character edits required to change one word into the other. Strings do not have to be the same length Hamming Distance : The number of … Read more

Understanding NSString comparison

The reason why == works is because of pointer comparison. When you define a constant NSString using @””, the compiler uniquifies the reference. When the same constants are defined in other places in your code, they will all point to the same actual location in memory. When comparing NSString instances, you should use the isEqualToString: … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)