Case insensitive search in Mongo

You can Use $options => i for case insensitive search. Giving some possible examples required for string match. Exact case insensitive string db.collection.find({name:{‘$regex’ : ‘^string$’, ‘$options’ : ‘i’}}) Contains string db.collection.find({name:{‘$regex’ : ‘string’, ‘$options’ : ‘i’}}) Start with string db.collection.find({name:{‘$regex’ : ‘^string’, ‘$options’ : ‘i’}}) End with string db.collection.find({name:{‘$regex’ : ‘string$’, ‘$options’ : ‘i’}}) Doesn’t … Read more

Scala multiple type pattern matching

You are missing the parenthesis for your case classes. Case classes without parameter lists are deprecated. Try this: abstract class MyAbstract case class MyFirst() extends MyAbstract case class MySecond() extends MyAbstract val x: MyAbstract = MyFirst() x match { case aOrB @ (MyFirst() | MySecond()) => doSomething(aOrB) case _ => doSomethingElse() } If you have … Read more

How is pattern matching in Scala implemented at the bytecode level?

The low level can be explored with a disassembler but the short answer is that it’s a bunch of if/elses where the predicate depends on the pattern case Sum(l,r) // instance of check followed by fetching the two arguments and assigning to two variables l and r but see below about custom extractors case “hello” … Read more

Does PostgreSQL support “accent insensitive” collations?

Update for Postgres 12 or later Postgres 12 adds nondeterministic ICU collations, enabling case-insensitive and accent-insensitive grouping and ordering. The manual: ICU locales can only be used if support for ICU was configured when PostgreSQL was built. If so, this works for you: CREATE COLLATION ignore_accent (provider = icu, locale=”und-u-ks-level1-kc-true”, deterministic = false); CREATE INDEX … Read more

Ruby Regexp group matching, assign variables on 1 line

You don’t want scan for this, as it makes little sense. You can use String#match which will return a MatchData object, you can then call #captures to return an Array of captures. Something like this: #!/usr/bin/env ruby string = “RyanOnRails: This is a test” one, two, three = string.match(/(^.*)(:)(.*)/i).captures p one #=> “RyanOnRails” p two … Read more