c# - Regular expression - extract 6 digits exactly -


YAV - edited to be clear

Hello, I want to find 6-digit numerical strings in text File Required Example:

  Text text text 123365 text text text   

Expression should now leave strings 6:

  text text text 1233656 text text text   

The above string should not return any result because the length of the digit string is 7.

I came up with this expression: [^ 0- 9] ([0- 9]) {6} [^ 0-9]

It works perfectly with the exception of the string which is at the beginning or end

  123365 text text text text text text text text text 123365   < P> Is it possible to identify these cases?   

Try:

  (? & Lt ;! \ D ) \ D {6} (?! \ D)   

It says:

  • Find 6 digits, which have not gone further Or are not successful with a single digit

    This will appear anywhere in the string.

    Example:

    123365 text text text text text text text text text 123365

    matchbox 123365

  • 123365

    123365 text text 234098 text text text text text text text 567890 text 123365

    1. 123365
    2. 234098
    3. 567890
    4. 123365

Comments