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 / C++ / MFC
  4. rsFind String in String

rsFind String in String

Scheduled Pinned Locked Moved C / C++ / MFC
jsonquestion
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.
  • W Offline
    W Offline
    wogerdoger
    wrote on last edited by
    #1

    Greetings All, Is there an API call to find a string within another ? How about with wildcard Chars How about with wildcard char[] (i.e a wildcard that represents any number of chars) ? Cheers If sex is a pain in the ass, then you are doing it wrong!

    S J 2 Replies Last reply
    0
    • W wogerdoger

      Greetings All, Is there an API call to find a string within another ? How about with wildcard Chars How about with wildcard char[] (i.e a wildcard that represents any number of chars) ? Cheers If sex is a pain in the ass, then you are doing it wrong!

      S Offline
      S Offline
      Steve S
      wrote on last edited by
      #2

      API no, library yes, _tcsstr, strstr. The wildcard stuff is a different issue. One way to do this is with regexp, although something that handles only ? and * is simpler. Steve S

      1 Reply Last reply
      0
      • W wogerdoger

        Greetings All, Is there an API call to find a string within another ? How about with wildcard Chars How about with wildcard char[] (i.e a wildcard that represents any number of chars) ? Cheers If sex is a pain in the ass, then you are doing it wrong!

        J Offline
        J Offline
        Jagadeesh VN
        wrote on last edited by
        #3

        try this function. It should work int Compare(const char* mask, const char* s) { const char* cp=0; const char* mp=0; for (; *s&&*mask!='*'; mask++,s++) if (*mask!=*s&&*mask!='?') return 0; for (;;) { if (!*s) { while (*mask=='*') mask++; return !*mask; } if (*mask=='*') { if (!*++mask) return 1; mp=mask; cp=s+1; continue; } if (*mask==*s||*mask=='?') { mask++, s++; continue; } mask=mp; s=cp++; } } "A robust program is resistant to errors -- it either works correctly, or it does not work at all; whereas a fault tolerant program must actually recover from errors."

        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