正则表达式识别字母数字的问题

发布于 2024-11-18 04:37:44 字数 248 浏览 8 评论 0原文

我正在尝试构建一个过滤字母数字字符串的正则表达式。这意味着类似“12ab”或“ab12”或“a12b”。我不能与单个字符或数字匹配。我的尝试是“[0-9a-zA-Z]+”。但这没有用。对我来说,说“字符串以字符或数字开头......”是一个问题,

这里有一些例子。

被认可: “aab2”“23ab”“a1”“a2acd”

不被识别: “a”“aads”“1”“232323”“。” “+”“sas+”

问候, 哈尼球

I am trying to build a regex which filters alphanumerical strings. That means something like "12ab" or "ab12" or "a12b". I must not match with single chars or numbers. My attempt was '[0-9a-zA-Z]+'. But this didn t work. For me it is a problem to say "the string starts with a character or a number ..."

Here some examples.

to be recognized:
"aab2" "23ab" "a1" "a2acd"

not to be recognized:
"a" "aads" "1" "232323" "." "+" "sas+"

Greetings,
Haniball

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

吻安 2024-11-25 04:37:44
^([a-zA-Z]+[0-9]+)|([0-9]+[a-zA-Z]+)[a-zA-Z0-9]*$
^([a-zA-Z]+[0-9]+)|([0-9]+[a-zA-Z]+)[a-zA-Z0-9]*$
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文