What does the “Nothing to repeat” error mean when using a regex in javascript?

You need to double the backslashes used to escape the regular expression special characters. However, as @Bohemian points out, most of those backslashes aren’t needed. Unfortunately, his answer suffers from the same problem as yours. What you actually want is: The backslash is being interpreted by the code that reads the string, rather than passed …

Read more

Jquery Value match Regex [duplicate]

Pass a string to RegExp or create a regex using the // syntax Call regex.test(string), not string.test(regex) So jQuery(function () { $(“.mail”).keyup(function () { var VAL = this.value; var email = new RegExp(‘^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$’); if (email.test(VAL)) { alert(‘Great, you entered an E-Mail-address’); } }); });

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