检查单词是否存在两次? (正则表达式) [英] Check if word exists twice? (Regex)

查看:87
本文介绍了检查单词是否存在两次? (正则表达式)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Regex上很恐怖,我想要的是检查一个字符串是否有两次单词http,例如: http://stackoverflow.com/questions/askhttp://stackoverflow.com / questions / ask ,在javascript中使用正则表达式的强大功能。

I am horrible at Regex, what i want is to check if a string has the word http twice, for example : http://stackoverflow.com/questions/askhttp://stackoverflow.com/questions/ask, using the awesome feature of regex in javascript.

谢谢。

推荐答案

/http.*http/

这是最简单的表达式。那就是 http 字符串中的任意位置后跟零个或多个字符后跟 http

Is the simplest expression that does this. That is http anywhere in the string followed by zero or more characters followed by http.

这篇关于检查单词是否存在两次? (正则表达式)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆