Part of String Case Insensitive in JavaScript Regex (?i) option not working

JavaScript built-in RegExp does not support inline modifiers, like (?im), let alone inline modifier groups that can be placed anywhere inside the pattern (like (?i:….)). Even XRegExp cannot offer this functionality, you can only use (?i) on the whole pattern declaring it at the pattern beginning. In XRegExp, you can define the regex ONLY as … Read more

Laravel Eloquent Ignore Casing

Use whereRaw with parameter binding to sanitize your whereRaw statement: $term = strtolower($vars[‘language’]); Item::whereRaw(‘lower(language) like (?)’,[“%{$term}%”])->get(); Prev answer In some dabases you can use operator ilike in your where. For example Item::where(‘language’, ‘ilike’, $vars[‘language’])->get(); All available operators are: protected $operators = array( ‘=’, ‘<‘, ‘>’, ‘<=’, ‘>=’, ‘<>’, ‘!=’, ‘like’, ‘not like’, ‘between’, ‘ilike’, ‘&’, … Read more

Ignore case in Python strings [duplicate]

Here is a benchmark showing that using str.lower is faster than the accepted answer’s proposed method (libc.strcasecmp): #!/usr/bin/env python2.7 import random import timeit from ctypes import * libc = CDLL(‘libc.dylib’) # change to ‘libc.so.6’ on linux with open(‘/usr/share/dict/words’, ‘r’) as wordlist: words = wordlist.read().splitlines() random.shuffle(words) print ‘%i words in list’ % len(words) setup = ‘from … Read more

Finding all possible case permutations in Python [duplicate]

def all_casings(input_string): if not input_string: yield “” else: first = input_string[:1] if first.lower() == first.upper(): for sub_casing in all_casings(input_string[1:]): yield first + sub_casing else: for sub_casing in all_casings(input_string[1:]): yield first.lower() + sub_casing yield first.upper() + sub_casing >>> [x for x in all_casings(“foo”)] [‘foo’, ‘Foo’, ‘fOo’, ‘FOo’, ‘foO’, ‘FoO’, ‘fOO’, ‘FOO’] >>> list(all_casings(“foo”)) [‘foo’, ‘Foo’, ‘fOo’, … Read more

GSON: How to get a case insensitive element from Json?

Unfortunately, registering a FieldNamingStrategy with the GsonBuilder wouldn’t do much good, as it translates only in the opposite-than-desired direction: from the Java field name to the JSON element name. It cannot be reasonably used for your purposes. (In Detail: The result of the translation request ends at FieldNamingStrategy.translateName(Field), where the translated name is used to … Read more

How can I make the map::find operation case insensitive?

It does not by default. You will have to provide a custom comparator as a third argument. Following snippet will help you… /************************************************************************/ /* Comparator for case-insensitive comparison in STL assos. containers */ /************************************************************************/ struct ci_less : std::binary_function<std::string, std::string, bool> { // case-independent (ci) compare_less binary function struct nocase_compare : public std::binary_function<unsigned char,unsigned char,bool> { … Read more