本文介绍了类似于SQL的JavaScript运算符“like”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

JavaScript中的运算符是否类似于<$ SQL中的c $ c>喜欢运算符?感谢解释和示例。

Is there an operator in JavaScript which is similar to the like operator in SQL? Explanations and examples are appreciated.

推荐答案

您可以使用来对字符串进行模式匹配。

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

例如:

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

match()测试很像 WHERE s LIKE'hello%'在SQL中。

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

这篇关于类似于SQL的JavaScript运算符“like”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-04 19:12