Thread: Search WILDCARD characer in STRING!!!!

  1. #1
    Registered User
    Join Date
    Apr 2010
    Posts
    23

    Search WILDCARD characer in STRING!!!!

    In my program i have a 2D array of strings and i want to implement a search function that can handle wildcard characters...
    For example the array has:
    Hello
    Good Morning
    Hello
    Good Evening

    And i type in the command "search M.orning"...
    i need the program to print out:
    Good Morning

    I think i need to compare character by character in the string but is there a function in <string.h> that can do that and how can i skip over the '.' character..

    Any help is greatly appreciated.

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    You can (1) write something to do what you want, once you determine what it is or (2) use a prebuilt regex engine.

    It's also not entirely clear how you want to get from "M.orning" to "Good Morning", so figuring out what you mean will help I would guess.

  3. #3
    Registered User
    Join Date
    Apr 2010
    Posts
    23
    um im not really sure what a regex engine is....
    BUT what i have done is separate the command "search M.orning" into two string. If the first string is equal to "search" it starts to look for a match. The second string has the word/phrase i want to find a match for...
    So what i need to do is compare M.orning with all the characters in my original array of strings...
    and then when it finds the character M it starts to look for an o straight after and when that is matched it needs to match r and so on.
    But for that to work i need to be able to skip the '.' character...
    How can that be done???

  4. #4
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    So how is this a wildcard? What purpose does the . serve? If it's just going to be ignored, skip it when you read it, or better yet, just strip it out of the string before you search for it.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Linked List Help
    By CJ7Mudrover in forum C Programming
    Replies: 9
    Last Post: 03-10-2004, 10:33 PM
  2. Another overloading "<<" problem
    By alphaoide in forum C++ Programming
    Replies: 18
    Last Post: 09-30-2003, 10:32 AM
  3. lvp string...
    By Magma in forum C++ Programming
    Replies: 4
    Last Post: 02-27-2003, 12:03 AM
  4. ........ed off at functions
    By Klinerr1 in forum C++ Programming
    Replies: 8
    Last Post: 07-29-2002, 09:37 PM
  5. Warnings, warnings, warnings?
    By spentdome in forum C Programming
    Replies: 25
    Last Post: 05-27-2002, 06:49 PM