简体   繁体   English

Reg Ex-查找字符串中的所有整数

[英]Reg Ex - Find all integers in string

I have a following value "1pm 2am" that I'm using a regular expression againts in SSIS to extract hours from in order to store separately. 我有一个以下值“ 1pm 2am”,我在SSIS中使用正则表达式Againts从中提取小时数以便分别存储。 I've tried using both of the regular expressions below but both only yield the first number "1". 我尝试使用下面的两个正则表达式,但是都只产生第一个数字“ 1”。

"(\d+)"
"(\*?\d{1,2}\*?)"

Am I missing something obvious? 我是否缺少明显的东西?

Use Regex.matches instead of Regex.match . 使用Regex.matches而不是Regex.match Regex.matches returns a collection of all matches. Regex.matches返回所有匹配项的集合。 Your regex can just be \\d+` by itself. Your regex can just be本身Your regex can just be \\ d +`。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM