text pattern matching(wildcard)
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: text pattern matching(wildcard)

  1. #1
    Join Date
    Jan 2009
    Posts
    20

    text pattern matching(wildcard)

    Hi all,

    I tried to make an matching between two strings the first is Pattern(" * weather * ") and the second is the user's input like User_str(" how is the weather in London? "), so these two strings matched as follows:

    the first star * = "how is the"
    weather = "weather"
    And the second star * = "in London?"

    The function should return true if matched and false if not.

    I know the idea of this function its an old but I have to build it from scratch for unicode strings with these restrictions

    the * if its attached to the text(ex. weather) should match zero or more characters.
    the * if its not attached to the text (ex. weather) should match one or more characters.
    the ? should match only one character whatever where it is.

    If anybody have an idea please let me know.

    Thanks alot

  2. #2
    Join Date
    Jul 2005
    Location
    Netherlands
    Posts
    2,013

    Re: text pattern matching(wildcard)

    Quote Originally Posted by hijjawi View Post
    I know the idea of this function its an old but I have to build it from scratch for unicode strings with these restrictions
    Why? Unless this is academic, that requirement makes no sense whatsoever.
    the * if its attached to the text(ex. weather) should match zero or more characters.
    the * if its not attached to the text (ex. weather) should match one or more characters.
    the ? should match only one character whatever where it is.

    If anybody have an idea please let me know.
    Find a library to work with regular expressions. Given the rules you describes, it's easy to translate the input into a regular expression. E.g. "zero or more characters" would be ".*".
    Cheers, D Drmmr

    Please put [code][/code] tags around your code to preserve indentation and make it more readable.

    As long as man ascribes to himself what is merely a posibility, he will not work for the attainment of it. - P. D. Ouspensky

  3. #3
    Lindley is offline Elite Member Power Poster
    Join Date
    Oct 2007
    Location
    Fairfax, VA
    Posts
    10,888

    Re: text pattern matching(wildcard)

    Boost.RegEx can do it.

  4. #4
    Join Date
    Jan 2009
    Posts
    20

    Re: text pattern matching(wildcard)

    Thanks for all but I need to make it without an regular expression using.

    I had some trials but still my function is not working well.

    I appreciate any help.

    Thanks

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center