在括号和冒号之间提取数字

时间:2016-07-13 09:19:56

标签: c# regex

我需要一个正则表达式从此字符串中提取数字 513922

  

检测到错误(513922:无法应用设置。),param d1 = 0.0,d2 = 0.0在操作模式下

1 个答案:

答案 0 :(得分:1)

如果你坚持正则表达式

 string source = 
   "Error detected (513922: settings can not be applied.), param d1=0.0, d2=0.0 in...";

 // 513922
 string result = Regex.Match(source, @"(?<=\()[0-9]+(?=:)").Value;
 // if you want integer representation:
 int number = int.Parse(result);