这个正则表达式 [...]+ 是如何处理的?
How is this regex [...]+ processessed?
我是 perl 新手(初学者,过去 1 周的空闲时间学习 perl)。这是我的第一门编程语言。
我想知道这个正则表达式 []+ 在 perl 中是如何工作的。我有 3 个问题。
- 这会做什么:
if /[\d\s\.,:\/]+/
?
我学会了 if /.../
匹配模式。
那么会匹配下面的吗?
下面哪些部分不匹配?
- 335.31, 312.52
- Dave1.532
- 路径:“./1243/453/48.1”
- 543, 546
编辑:
这不是链接问题的重复,因为我特别询问 []+
是如何工作的。链接 post 中的答案不包括这一点。
我知道上面写的正则表达式中的每个字符代表什么以及每个字符的工作原理。我想知道的是 []+
将如何影响正则表达式。具体来说 +
将如何影响 []
。
我建议您使用regex101.com 来尝试正则表达式。以下是您提供的表达式的细分:
`[]` match a single character present in the list
`+` matches one or more of the above
`\d` match a digit [0-9]
`\s` match any white space character `[\r\n\t\f ]`
`\.` matches the character . literally
`,:` a single character in the list ,: literally
`\/` matches the character / literally
您将获得以下匹配项(如果您 运行 使用 g
- 全局选项)-(REGEX 示例 - ref):
`335.31, 312.52 `
`1.532 `
`: `
`./1243/453 /48.1`
` 543, 546 `
我是 perl 新手(初学者,过去 1 周的空闲时间学习 perl)。这是我的第一门编程语言。
我想知道这个正则表达式 []+ 在 perl 中是如何工作的。我有 3 个问题。
- 这会做什么:
if /[\d\s\.,:\/]+/
?
我学会了 if /.../
匹配模式。
那么会匹配下面的吗?
下面哪些部分不匹配?
- 335.31, 312.52
- Dave1.532
- 路径:“./1243/453/48.1”
- 543, 546
编辑:
这不是链接问题的重复,因为我特别询问 []+
是如何工作的。链接 post 中的答案不包括这一点。
我知道上面写的正则表达式中的每个字符代表什么以及每个字符的工作原理。我想知道的是 []+
将如何影响正则表达式。具体来说 +
将如何影响 []
。
我建议您使用regex101.com 来尝试正则表达式。以下是您提供的表达式的细分:
`[]` match a single character present in the list
`+` matches one or more of the above
`\d` match a digit [0-9]
`\s` match any white space character `[\r\n\t\f ]`
`\.` matches the character . literally
`,:` a single character in the list ,: literally
`\/` matches the character / literally
您将获得以下匹配项(如果您 运行 使用 g
- 全局选项)-(REGEX 示例 - ref):
`335.31, 312.52 `
`1.532 `
`: `
`./1243/453 /48.1`
` 543, 546 `