简体   繁体   中英

C#: Regex with digits and slash in the middle

So i have string with digits and words for example:

1283677/10, this is my string, bla bla

And i want to take only the serial number: 1283677/10

This is what i have try:

Match match = Regex.Match(text, @"\d{8}(/\d{1,2})?");

Currently return empty.

You have 7 digits in the part before slash. So the fix is fair simple:

Match match = Regex.Match(text, @"\d{7}(/\d{1,2})?");

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