Good Python modules for fuzzy string comparison? [closed]

difflib can do it. Example from the docs: >>> get_close_matches(‘appel’, [‘ape’, ‘apple’, ‘peach’, ‘puppy’]) [‘apple’, ‘ape’] >>> import keyword >>> get_close_matches(‘wheel’, keyword.kwlist) [‘while’] >>> get_close_matches(‘apple’, keyword.kwlist) [] >>> get_close_matches(‘accept’, keyword.kwlist) [‘except’] Check it out. It has other functions that can help you build something custom.

How can I do a case insensitive string comparison?

This is not the best practice in .NET framework (4 & +) to check equality String.Compare(x.Username, (string)drUser[“Username”], StringComparison.OrdinalIgnoreCase) == 0 Use the following instead String.Equals(x.Username, (string)drUser[“Username”], StringComparison.OrdinalIgnoreCase) MSDN recommends: Use an overload of the String.Equals method to test whether two strings are equal. Use the String.Compare and String.CompareTo methods to sort strings, not to check … Read more

Case-insensitive search

Yeah, use .match, rather than .search. The result from the .match call will return the actual string that was matched itself, but it can still be used as a boolean value. var string = “Stackoverflow is the BEST”; var result = string.match(/best/i); // result == ‘BEST’; if (result){ alert(‘Matched’); } Using a regular expression like … Read more

MySQL query String contains

Quite simple actually: SELECT * FROM `table` WHERE `column` LIKE ‘%{$needle}%’ The % is a wildcard for any characters set (none, one or many). Do note that this can get slow on very large datasets so if your database grows you’ll need to use fulltext indices.

How do I compare version numbers in Python?

Use packaging.version.parse. >>> # pip install packaging >>> from packaging import version >>> version.parse(“2.3.1”) < version.parse(“10.1.2”) True >>> version.parse(“1.3.a4”) < version.parse(“10.1.2”) True >>> isinstance(version.parse(“1.3.a4”), version.Version) True >>> isinstance(version.parse(“1.3.xy123”), version.LegacyVersion) True >>> version.Version(“1.3.xy123”) Traceback (most recent call last): … packaging.version.InvalidVersion: Invalid version: ‘1.3.xy123’ packaging.version.parse is a third-party utility but is used by setuptools (so you probably … Read more

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