Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How can I use regex to match CSV record?

How can I use regex to match CSV record?

Scheduled Pinned Locked Moved C#
regexquestionhelp
6 Posts 4 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    stormydaniels
    wrote on last edited by
    #1

    My file contains records which look like this: EMPLOYEE001,M,20081105 First column is employee ID, second is gender and third is date. I want to read this from a comma separated variable text file and think a regular expression is the way to do it. I do not want to create a dataset from the file. Help much appreciated :)

    A L T 3 Replies Last reply
    0
    • S stormydaniels

      My file contains records which look like this: EMPLOYEE001,M,20081105 First column is employee ID, second is gender and third is date. I want to read this from a comma separated variable text file and think a regular expression is the way to do it. I do not want to create a dataset from the file. Help much appreciated :)

      A Offline
      A Offline
      Ashfield
      wrote on last edited by
      #2

      Member 5646867 wrote:

      Help much appreciated

      To do what? You haven't asked a question, and a regular expression will not read records from a file.

      Bob Ashfield Consultants Ltd

      S 1 Reply Last reply
      0
      • S stormydaniels

        My file contains records which look like this: EMPLOYEE001,M,20081105 First column is employee ID, second is gender and third is date. I want to read this from a comma separated variable text file and think a regular expression is the way to do it. I do not want to create a dataset from the file. Help much appreciated :)

        L Offline
        L Offline
        led mike
        wrote on last edited by
        #3

        Member 5646867 wrote:

        and think a regular expression is the way to do it.

        And you are basing that on? If you don't know how to use regular expressions, why do you think that's the way to do it?

        led mike

        S 1 Reply Last reply
        0
        • A Ashfield

          Member 5646867 wrote:

          Help much appreciated

          To do what? You haven't asked a question, and a regular expression will not read records from a file.

          Bob Ashfield Consultants Ltd

          S Offline
          S Offline
          stormydaniels
          wrote on last edited by
          #4

          Sorry for not being more clear. I will use a regular expression to validate my record I read from the .csv file. Like this:

          Regex regex = new Regex(expression);
          string[] parts = regex.Split(record);

          Sorry again :^)

          1 Reply Last reply
          0
          • L led mike

            Member 5646867 wrote:

            and think a regular expression is the way to do it.

            And you are basing that on? If you don't know how to use regular expressions, why do you think that's the way to do it?

            led mike

            S Offline
            S Offline
            stormydaniels
            wrote on last edited by
            #5

            Please see my answer above :) Sorry, but I thought I wouldn't need to explain that I could get the record from the .csv text file.

            1 Reply Last reply
            0
            • S stormydaniels

              My file contains records which look like this: EMPLOYEE001,M,20081105 First column is employee ID, second is gender and third is date. I want to read this from a comma separated variable text file and think a regular expression is the way to do it. I do not want to create a dataset from the file. Help much appreciated :)

              T Offline
              T Offline
              thowra
              wrote on last edited by
              #6

              This: ",(?=([^\"]*\"[^\"]*\")*(?![^\"]*\"))"

              Evil cannot be conquered in the world... It can only be resisted within oneself.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups