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. string.Compare using wildcards

string.Compare using wildcards

Scheduled Pinned Locked Moved C#
help
3 Posts 2 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.
  • M Offline
    M Offline
    melanieab
    wrote on last edited by
    #1

    Hi, I'm trying to search a datagrid/datatable using string.Compare, and doing something wrong when trying to use wildcards. I have searchThis as the string to search for, which works fine with string.Compare(search, searchThis);. But when I try to make searchThis = "*" + searchThis + "*"; it doesn't work. I'm sure it's pretty simple, but haven't been able to find the answer yet. Thanks for any help! Mel

    D 1 Reply Last reply
    0
    • M melanieab

      Hi, I'm trying to search a datagrid/datatable using string.Compare, and doing something wrong when trying to use wildcards. I have searchThis as the string to search for, which works fine with string.Compare(search, searchThis);. But when I try to make searchThis = "*" + searchThis + "*"; it doesn't work. I'm sure it's pretty simple, but haven't been able to find the answer yet. Thanks for any help! Mel

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      The Compare method doesn't support wildcards. If you want to search entire strings with wildcard support, you'll have to use Regular Expressions[^]. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

      M 1 Reply Last reply
      0
      • D Dave Kreskowiak

        The Compare method doesn't support wildcards. If you want to search entire strings with wildcard support, you'll have to use Regular Expressions[^]. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

        M Offline
        M Offline
        melanieab
        wrote on last edited by
        #3

        Thanks! Mel

        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