简体   繁体   中英

C# - String that contains varying digits

I have a method that checks to see if a string (lets say "strparent") contains another string ("strsub") but the thing is, "strsub" does not always contain the same value as there is a digit within it that can be any whole digit.

Example 1:

" tab (ver 3) by "

Example 2:

" tab (ver 12) by "

I'm not too experienced with regular expressions so I'm not sure if this could be easily done with them or not.

\(substr \d+\)

使用此正则表达式

Regex would be simple (untested): @" tab \\(ver \\d+\\) by ";

This is a handy regular expression tester for C#:

It should be fairly easy. I would just tell you but regular expressions are probably something you should familiarize yourself with and this would be a good first attempt as the expression would not be very complex.

Some REGEX resources:

http://regexlib.com/CheatSheet.aspx

http://www.regular-expressions.info/dotnet.html

http://www.codeproject.com/KB/dotnet/regextutorial.aspx

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