Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/334.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/opengl/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 用于字母数字通配符搜索的正则表达式_Javascript_C#_Regex_Asp.net Mvc - Fatal编程技术网

Javascript 用于字母数字通配符搜索的正则表达式

Javascript 用于字母数字通配符搜索的正则表达式,javascript,c#,regex,asp.net-mvc,Javascript,C#,Regex,Asp.net Mvc,我需要一个搜索框的正则表达式,该搜索框只接受字母数字值,但允许通过在末尾使用“*”进行通配符搜索 类似于“123*”、“abc*”或只是“abc” 但是上面的一个在任何位置都有多个*字符。我想把这个限制在一个范围内,如果可能的话,也要限制在最后 谢谢你的帮助 谢谢 类似这样: ^[a-zA-Z0-9]+\*?$类似这样的内容: ^[a-zA-Z0-9]+\*?$使用此正则表达式/(^\w+\*$)|(^\w+$)/g可以匹配abc或abc* 或另一种方式:^\w+\*?$ \*?$:最后为可选*

我需要一个搜索框的正则表达式,该搜索框只接受字母数字值,但允许通过在末尾使用“*”进行通配符搜索

类似于“123*”、“abc*”或只是“abc”

但是上面的一个在任何位置都有多个*字符。我想把这个限制在一个范围内,如果可能的话,也要限制在最后

谢谢你的帮助

谢谢

类似这样:
^[a-zA-Z0-9]+\*?$

类似这样的内容:
^[a-zA-Z0-9]+\*?$

使用此正则表达式
/(^\w+\*$)|(^\w+$)/g
可以匹配
abc
abc*

另一种方式:
^\w+\*?$

\*?$
:最后为可选*

^\w
:开头有一个或多个单词

const regex=/(^\w+\*$)|(^\w+$)/g;
const text=“abc”
console.log(text.match(regex))
使用此正则表达式
/(^\w+\*$)|(^\w+$)/g
您可以匹配
abc
abc*

另一种方式:
^\w+\*?$

\*?$
:最后为可选*

^\w
:开头有一个或多个单词

const regex=/(^\w+\*$)|(^\w+$)/g;
const text=“abc”

console.log(text.match(regex))
\w
不仅匹配
[a-zA-Z0-9]
它还匹配什么?至少是
\uu
和其他字符,取决于regex引擎谢谢我会更新我的答案,但另一个问题你说的regex引擎是什么意思?是的,这就是我的意思,我相信我在一些遗留技术方面有过这种不愉快的经历,但通常
\w
匹配
[a-zA-Z!]
\w
不仅匹配
[a-zA-Z0-9]
它还匹配什么?至少
\u
和其他字符取决于regex engine谢谢我会更新我的答案但另一个问题regex engine是什么意思使用的语言正确吗?是的,这就是我的意思,我相信我在一些遗留技术方面有过不愉快的经历,但是通常
\w
匹配
[a-zA-Z!]
  $(".onlyAlphaNumericWildcard").keypress(function (e) {
     //Alphanumeric and also an optional "*" at the end
     var keyCode = e.which;
     var inp = String.fromCharCode(keyCode);
     if (/[a-zA-Z0-9*]/.test(inp)) {
        return true;
     }
     return false;
   });