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. Regex question

Regex question

Scheduled Pinned Locked Moved C#
regexquestionjsonhelp
3 Posts 3 Posters 0 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.
  • K Offline
    K Offline
    kanchoette
    wrote on last edited by
    #1

    I hace some code which starts: if (textBox1.Text.Length > 0) { String pat = "*.csv"; Regex r = new Regex (pat, RegexOptions.IgnoreCase); Match m = r.Match(textBox1.Text); if (m.Success) { GetCSV(textBox1.Text); } which is giving me the error: "parsing "*.csv" - Quantifier {x,y} following nothing." What am I doing wrong please?

    OriginalGriffO P 2 Replies Last reply
    0
    • K kanchoette

      I hace some code which starts: if (textBox1.Text.Length > 0) { String pat = "*.csv"; Regex r = new Regex (pat, RegexOptions.IgnoreCase); Match m = r.Match(textBox1.Text); if (m.Success) { GetCSV(textBox1.Text); } which is giving me the error: "parsing "*.csv" - Quantifier {x,y} following nothing." What am I doing wrong please?

      OriginalGriffO Offline
      OriginalGriffO Offline
      OriginalGriff
      wrote on last edited by
      #2

      Everything? Regex pattern patching is not as simple as "*.xxx" for file name: '*' means "repeated zero or more times" and '.' means any character. If you are trying to match the entire text box with a wild card filename, then why not just do:

      if (textBox1.Text == "*.csv")
      {
      ...
      }

      since that will work.

      No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced. This message is made of fully recyclable Zeros and Ones "Rumour has it that if you play Microsoft CDs backwards you will hear Satanic messages.Worse still, is that if you play them forwards they will install Windows"

      "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
      "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

      1 Reply Last reply
      0
      • K kanchoette

        I hace some code which starts: if (textBox1.Text.Length > 0) { String pat = "*.csv"; Regex r = new Regex (pat, RegexOptions.IgnoreCase); Match m = r.Match(textBox1.Text); if (m.Success) { GetCSV(textBox1.Text); } which is giving me the error: "parsing "*.csv" - Quantifier {x,y} following nothing." What am I doing wrong please?

        P Offline
        P Offline
        PIEBALDconsult
        wrote on last edited by
        #3

        Or something like if ( textBox1.Text.EndsWith ( ".csv" ) ) ... But I would likely use a System.IO.FileInfo and check its Extension property.

        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