Pattern matching NEED HELP 
Author Message
 Pattern matching NEED HELP

Hi,

I would like to write a program for pattern matching like pattern in flex
or lex. However, the input to this program does not get from file or other
standard input. My idea, I want to pass a string to this procedure, and
return TRUE, if that pattern match and FALSE if it does no match.

In the procedure, I have many patterns. Each pattern does not specific in
some characters.

I found that lex or flex provides any easy ways to do. Unfortunately, the
input string must read from file.

Any has other idea, I will appreciate. Thank you.

Chuleerat



Sun, 25 Apr 1999 03:00:00 GMT  
 Pattern matching NEED HELP



Quote:
> Hi,

> I would like to write a program for pattern matching like pattern in flex
> or lex. However, the input to this program does not get from file or
other
> standard input. My idea, I want to pass a string to this procedure, and
> return TRUE, if that pattern match and FALSE if it does no match.

> In the procedure, I have many patterns. Each pattern does not specific in
> some characters.

> I found that lex or flex provides any easy ways to do. Unfortunately, the
> input string must read from file.

> Any has other idea, I will appreciate. Thank you.

> Chuleerat

This isn't exactly what you're looking for but it should be somewhat
similar. str_count counts the number of substrings in a string, so if the
function returns a value greater than 0 you've found the substring. For use
with files you can read a block of characters into string and call the
function before moving on to the next block.

Prototype:
int str_count ();

Function Call:
if (str_count(substr, string) > 0)
    return(TRUE);
else
    return(FALSE);

Function:
int str_count (char substr[], char str[])
{
    int i, j, k, count = 0;
    for (i = 0; str[i]; i++)
        for (j = i, k = 0; str[j] == substr[k]; j++, k++)
            {
            if (! substr[k+2])
                count++;
            }
    return (count);

- Show quoted text -

Quote:
}



Mon, 26 Apr 1999 03:00:00 GMT  
 Pattern matching NEED HELP

Quote:

>Hi,
>I would like to write a program for pattern matching like pattern in flex
>or lex. However, the input to this program does not get from file or other
>standard input. My idea, I want to pass a string to this procedure, and
>return TRUE, if that pattern match and FALSE if it does no match.

Perhaps the regexp package helps. It can be found on most
Unixlike computers and its certainly available for PC.
Nethertheless as far as I know lex can be adapted to work
on strings.

h.f.s.
--
Hans Friedrich Steffani
Institut fuer Elektrische Maschinen und Antriebe, TU Chemnitz-Zwickau

http://www.tu-chemnitz.de/~hfst/



Mon, 26 Apr 1999 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Regular Expressions/Pattern Matching/Unordered pattern

2. Help, Pattern used in Regex.Matches(...)

3. help with a fast pattern matching utility requested

4. Help with Pattern Matching!

5. pattern matching help

6. Help on string pattern matching?

7. Pattern Matching in VC++ Help...

8. Pattern Matching in C -

9. Pattern Matching Tool

10. Pattern Matching in C

11. pattern matching and string replacement

12. Pattern Matching in execution time

 

 
Powered by phpBB® Forum Software