【问题标题】:change wp results page depending on its url根据其 url 更改 wp 结果页面
【发布时间】:2018-07-04 17:31:23
【问题描述】:

我希望你能帮助我解决这个问题。我需要能够在 js 中构建一个正则表达式,它允许字母、数字和符号,例如加号 (+) 就在 ?s=...

现在我正在尝试这样的事情

var regexp = '^[a-z0-9]';
if (url == 'https://digitalswitch.cl/rileditores/?s=' + regexp){
   //do something
}else{
   //do something else
}

【问题讨论】:

标签: javascript jquery wordpress


【解决方案1】:

var str     = "https://digitalswitch.cl/rileditores/?s=sample";
var matches = str.match(/\?s=([^&]*)/);
if(matches){
   alert('matched');
}else{
   alert('not matched');
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

以下示例将搜索“?s”在链接中是否可用。如果是警报“匹配”,否则“不匹配”。

希望对你有帮助。

更多例子,

【讨论】:

    猜你喜欢
    • 2021-01-16
    • 1970-01-01
    • 1970-01-01
    • 2012-02-15
    • 1970-01-01
    • 1970-01-01
    • 2021-05-15
    • 2013-05-29
    • 1970-01-01
    相关资源
    最近更新 更多