正则表达式内方括号可选的文本在括号内的数字相匹配 [英] Regular Expression to match numbers inside parenthesis inside square brackets with optional text

查看:250
本文介绍了正则表达式内方括号可选的文本在括号内的数字相匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,我在C#在这里,这样的正则表达式的我处理的味道。这里有一点事情,我需要能够匹配:

Firstly, I'm in C# here so that's the flavor of RegEx I'm dealing with. And here are thing things I need to be able to match:

[(1)]

[(34) Some Text - Some Other Text]

所以基本上我需要知道什么是括号是数字而忽略了右括号和右方括号之间的一切。任何正则表达式大师关心帮助

So basically I need to know if what is between the parentheses is numeric and ignore everything between the close parenthesis and close square bracket. Any RegEx gurus care to help?

推荐答案

这应该工作:

\[\(\d+\).*?\]

如果你需要赶上号码,只需换 \d + 在括号:

And if you need to catch the number, simply wrap \d+ in parentheses:

\[\((\d+)\).*?\]

这篇关于正则表达式内方括号可选的文本在括号内的数字相匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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