JavaScript operator similar to SQL "like"

javascript

Solution

You can use regular expressions in Javascript to do pattern matching of strings.

For example:

var s = "hello world!";
if (s.match(/hello.*/)) {
  // do something
}

The `match()` test is much like `WHERE s LIKE 'hello%'` in SQL.

Problem

Possible Duplicate: Emulating SQL LIKE in JavaScript Is there an operator in JavaScript which is similar to the `like` operator in SQL? Explanations and examples are appreciated.

Original source

Related problems