c# regex get strings that have a specific sequence of letters and digits -


i've searched around here haven't found satisfying answer i've decided ask. need search collection of strings find expressions like:

ab 12345 ac 12345 

i've tried regex

[a][bc][ ]\d{5} 

but unfortunately in strings there also

#xxab 1234567890123 ggab 12345678901 ab 123456 sab 123456789 

and above expression gets these valid. i've found , tried

[a][bc][ ]\d{5}$ 

but not match anything.

so question is, there expression find strings 5 numbers followed except more numbers?

from answers think not clear in exposition, strings in middle of larger string set possible string must match:

my description data xxxab 12345bcd  

and also

my second description data ref. ab 12345 

and also

my third description data refab 12345 

and also

ab 12345with description following ab 12345 space , description following 

the strings uppercase in database.

use ?! lookahead.

a[bc] \d{5}(?!\d) 

see demo.

https://regex101.com/r/or7zj6/2


Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

unity3d - Fatal error- Monodevelop-Unity failed to start -