在指定字符之后使用Regex匹配序列
初始字符串是 [图像:Salmon-V5-09-14-2011.jpg]
我想捕获文本“ Salmon-V5-09-14-2011.jpg”,并使用 gskinner的正则福克斯工具
我能获得的最接近我所需的输出的最接近的是使用此言论:
:([\w+.-]+)
问题是,这个序列包括该序列包括colon colon colon 输出
:salmon-v5-09-14-2011.jpg
如果没有结肠, 如何捕获所需的输出。感谢您的帮助!
The initial string is [image:salmon-v5-09-14-2011.jpg]
I would like to capture the text "salmon-v5-09-14-2011.jpg" and used GSkinner's RegEx Tool
The closest I can get to my desired output is using this RegEx:
:([\w+.-]+)
The problem is that this sequence includes the colon and the output becomes
:salmon-v5-09-14-2011.jpg
How can I capture the desired output without the colon. Thanks for the help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使用外观范围:
look-behind(编码为
(?< = somereGex)
)是一个零宽的匹配,因此它断言,但并未捕获匹配项。另外,您的正则表达式可能可以简化:
它只是抓住(但不包括)
:
和a ] 之间的任何内容Use a look-behind:
A look-behind (coded as
(?<=someregex)
) is a zero-width match, so it asserts, but does not capture, the match.Also, your regex may be able to be simplified to this:
which simply grabs anything between (but not including) a
:
and a]
如果您一直以这种格式查看字符串,我将使用此模式:
这是
的后面。
If you are always looking at strings in that format, I would use this pattern:
This looks behind for
[image:
, then matches until the closing]
您只有正确的正则是您使用的工具,而是突出显示整个比赛,而不仅仅是您的捕获组。在比赛中徘徊,看看“第1组”实际是什么。
如果您想要更强大的正则义务。
You have the correct regex only the tool you're using is highlighting the entire match and not just your capture group. Hover over the match and see what "group 1" actually is.
If you want a slightly more robust regex you could try
:([^\]]+)
which will allow for any characters other than]
to appear in the file name portion.