Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Lexical Analysis

sigma_zksigma_zk Posts: 68Member
I need the pseudocode for an algorithm that matches strings based on a pattern based on DOS wildcards:
? matches any one character.
* matches zero or more characters, as many characters as possible.
any other character matches that character.
The pattern must match the entire string perfectly or it is a failure.

The * is the thing that is giving me the most trouble, by the way.

Comments

  • iapiap Posts: 6Member
    : The * is the thing that is giving me the most trouble, by the way.
    :

    Ok, I can't write it in paseudo code, but I can give you the idea:

    try splitting your query string to sections, when the * is the seperator:

    "A*B*CD" -> ["A","B","CD"]

    the compare each of the sections with the data string, checking in each compiration that the index of the mach (if found) is bigger then the index of the mach of the previous section.

    "AdfsBtfgCD"
    index of "A" is 1.
    index of "B" is 5 - bigger then 1.
    index of "CD" is 9 - bigger then 5.
    string mach.

    I hope I'm clear....

  • sigma_zksigma_zk Posts: 68Member
    I just made it so * grabs the rest of the string and backtracks recursively until it finds a match. Thanks anyways tho' :-).
Sign In or Register to comment.