[A-z0-9]+ 正则表达式匹配方括号 [英] [A-z0-9]+ regexp matching square brackets

查看:40
本文介绍了[A-z0-9]+ 正则表达式匹配方括号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为以下正则表达式苦苦挣扎

I'm struggling with the following regexp

[A-z0-9]+

如果针对此字符串进行测试:

If tested against this string:

||a919238[.--a]asd|

它返回a919238[,包括方括号..我试图输入我的测试用例在 regex101 上了解出了什么问题,但是站点 regex 解释没有帮助,可能我看不到我的错误.

it returns a919238[, including the square bracket.. I tried to input my test case on regex101 to understand what's wrong, but the site regex explanation is not helping, probably I'm not able to see my mistake.

为什么结果中包含方括号?

Why is the square bracket included in the result?

推荐答案

因为

[A-z0-9]+ 
 ↑ ↑ 

是从Az,看ASCII表,]出现在两个字符之间:

is from A to z, see the ASCII table, ] appears between the two characters:

这篇关于[A-z0-9]+ 正则表达式匹配方括号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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