C#,正则表达式找到但找不到b [英] C#, regex to find a but not find b

查看:91
本文介绍了C#,正则表达式找到但找不到b的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在预付银行的付款详情,我希望正则表达式找到例如12345的值,但在12345-123或123456-12345时找不到任何内容。

当我使用\d {4,6}(?!\d {0,2} -\d {3})时表达

它找到了12345但它也从表达式中找到12345(123456-12345)

任何想法?

I am foreaching a payment details in the bank, I want the regex to find value for example 12345 but not find anything when its 12345-123 or 123456-12345.
When I use \d{4,6}(?!\d{0,2}-\d{3}) expression
It finds 12345 but it also finds 12345 from the expression(123456-12345)
Any ideas?

推荐答案

为什么不能这样:

Why not something like:
(?: )(\d*)((?: )|




您可以使用Expresso根据需要修改表达式


And you could use Expresso to modify the expression to your needs


这篇关于C#,正则表达式找到但找不到b的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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