正则表达式表达式 [英] Regex expression fucntion

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

问题描述

我有以下输入字符串:

+ 20A,100A,E + 40,100 +,RK100H



我想从输入中提取下面的输出:

+ 20A,E + 40,100 +



我的当前功能只输出E + 20字符串而不输出+ 20A字符串。

  foreach  var  match 中的class =code-keyword> Regex.Matches(list, @  [a-zA- z] + \ + \d +))
{
// 在此输出每个匹配项
string b = ;
b + = match.ToString();
行[ Spre] = b;
行[ Spre Value] = ;
行[ 6 ] = x;
}





我的表达中是否有遗漏的东西?谢谢

解决方案

试试这个:(\ + \d + [a-zA-Z])|(。\ + \ d +)|(\d + \ +)

I have the following input string:
+20A, 100A, E+40, 100+, RK100H

I would like to extract the output below from the input:
+20A, E+40, 100+

My current function is only outputting E+20 string but not the +20A string.

foreach (var match in Regex.Matches(list, @"[a-zA-z]+\+\d+"))
                                 {
                                     // Output each match here
                                     string b = "";
                                     b += match.ToString();
                                     row["Spre"] = b;
                                     row["Spre Value"] = value;
                                     row[6] = x;
                                 }



Is there something I am missing from my expression? Thanks

解决方案

Try this: (\+\d+[a-zA-Z])|(.\+\d+)|(\d+\+)


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

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