News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

WldMatchA

Started by TNick, January 29, 2007, 04:38:17 PM

Previous topic - Next topic

TNick

Well, here is a "wildcard string pattern matching" function that I've wrote today. If there are some other functions that do the same thing, please supply me with the link, so I can add those in the test. Present function takes two arguments - the string in which we are searching and the pattern to search - and returns an 0 based offset if it finds something and  -1 otherwise.
Further improvements are welcome, as always!


[later]
1) some minor improvements
2) the bug pointed by Jibz was fixed
3) as zooba suggested, the offset was easy to compute. I just couldn't see the forest because of the trees.
[/later]

[attachment deleted by admin]

Jibz

If I am not mistaken, your implementation may fail if the string being matched contains wildcard characters.

An example would be matching the pattern "A*C" against the string "A*BC".

TNick

Jibz,

thanks for tacking the time to have a look and thanks for pointing that mistake!!! I've fixed the bug.

Regards,
Nick

zooba

(continued from the other pattern matching thread)

I haven't compiled and tried your function with sample data to test this but I wonder: If you search for "*ings.", will it check against "things," and say it found nothing since the full-stop doesn't match the comma, or will it continue until it reaches "kings." and give a true positive?

Nice work :wink

Cheers,

Zooba :U

TNick

Hello again, zooba!

Quote from: zooba on January 31, 2007, 08:33:43 PM
Nice work :wink
Thanks!

Quote from: zooba on January 31, 2007, 08:33:43 PM
If you search for "*ings.", will it check against "things," and say it found nothing since the full-stop doesn't match the comma, or will it continue until it reaches "kings." and give a true positive?

The function doesn't test for any other specific character but * and ? in pattern. It treats everything else as bytes values that should be equal.
I've created this function for a search engine to be used in a snippets database program, and I was thinking it should be enough to do this. To search files - for example - an improvement in direction that you pointed would be required.

Thanks for this second great suggestion, BTW!  :U

Regards,
Nick


TNick

Hello all!

This is a package of 3 functions that have the same purpose: to find a
pattern within a target string and to return the position where the pattern
was found or -1 if there was no match. The search is case sensitive.

The first function (WldMatch_01) is the function that i've posted at the top of this thread.
The second (WldMatch_02) is a play around a lookup table. I am very
disappointed by this one, since I've work a lot to make it run and it
has such lazy times, probably because of jmp dword ptr [edx+OFFSET ...].
The third one (WldMatch_03) is based on the first function and it has the
best speed on most tests.

The time was measured using MichaelW timer macros, and the value that is shown
at the right of each line is the minimum value from x tests. In the summary,
there is just a sum of all values returned by timer macros for each
function, but is (almost) meaningless on statistical point of view.

Regards,
Nick


[attachment deleted by admin]