RegEx with Text File

Hi All,
I have to read a text file that's follow bellow:

int#string#string
int#string#string
int#string#string
...

I would like me read this using RegEx and StreamReader classes.

I want to use RegEx to create a format validator.
,and StreamReader in order to do my code clearer.

Thanks for all in advance.

--JORDI--


Answer this question

RegEx with Text File

  • mig16

    I'm guessing you are asking for a Regular Expression to validate this how about something like this.

    with grouping:
    ^(\d )#([^#])#([^#])$

    without grouping:
    ^\d #[^#]#[^#]$


    This will help you understand what this regex means.

    http://msdn.microsoft.com/library/default.asp url=/library/en-us/cpgenref/html/cpconRegularExpressionsLanguageElements.asp


  • MiltGrin

    Here is a regex that captures every line that matches the format "int#string#string"

    (\d+)#([^#\r\n]+)#([^#\r\n]+)( =[\r\n]*|1$)




  • RegEx with Text File