简体   繁体   中英

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. I've tried using both of the regular expressions below but both only yield the first number "1".

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

Am I missing something obvious?

Use Regex.matches instead of Regex.match . Regex.matches returns a collection of all matches. Your regex can just be \\d+` by itself.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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