正则表达式 截取必须以一个字符串开头,并且可能有多个这样的字符串

例子 “要截取字符串”+任意字符串+“要截取字符串”+任意字符
这只是个例子: aa是要截取的字符串 aapokmuiaapokiiioaa
求正则表达式

不知道你在哪里使用,这里用 js 做为测试,你把如下的内容保存为 html 文件后,浏览器开启允许脚本功能,就可以测试了。
相应的正则表达式是:^(?!l-en|l-zh).*$

你可以输入测试字串测试看结果,比如:
l-zhxxxxx 不匹配
l-enyyyyy 不匹配
len 匹配
lzn 匹配
xxxx 匹配

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<html>
<head>
<script type="text/javascript">
function check()
{
var str;
str = document.getElementById("txtInput").value;
if (str.match(/^(?!l-en|l-zh).*$/) != null)
{
alert("匹配");
}
else
{
alert("不匹配");
}
}
</script>
</head>
<body>
输入:<input type="text" id="txtInput" />
<button type="button" onclick="check()">正则检查</button>
</form>
</body>
</html>
温馨提示:答案为网友推荐,仅供参考
相似回答