pattern matching

This is a discussion on pattern matching within the C Programming forums, part of the General Programming Boards category; Can someone give me an example of how you do pattern matching in a string? For instance, if there's more ...

  1. #1
    Registered User
    Join Date
    Dec 2002
    Posts
    10

    Question pattern matching

    Can someone give me an example of how you do pattern matching in a string? For instance, if there's more than one decimal point in a string, or if there is a + or - that's embedded in the string / not the leading character of the string?

    Thanks!

  2. #2
    ggs
    ggs is offline
    C > C++ duders ggs's Avatar
    Join Date
    Aug 2001
    Posts
    435
    regexp can be used to deal with things like this.. but i don't know how to use it

    you could break the string down into fields, maybe one type for all numbers, another type for a decimal or a plus.. and then use a simple test of the sequence of fields (maybe driven by a table) to figure out which format the string is in. (to build the fields, you might use a linked list and loop through the string, adding a new field after processing all the data that belongs in a single field..)
    .sect signature

  3. #3
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    strstr - find a string in a string
    strchr - find a character in a string

    Quzah.
    Hope is the first step on the road to disappointment.

  4. #4
    CS Author and Instructor
    Join Date
    Sep 2002
    Posts
    511

    Wink

    There are two major pattern matching algoritims:

    Boyer-Moore and KMP- Knuth Morris Pratt

    check them out
    Mr. C: Author and Instructor

  5. #5
    Registered User
    Join Date
    Jan 2003
    Posts
    99
    Does C support Regular Expressions?

  6. #6
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Originally posted by _Cl0wn_
    Does C support Regular Expressions?
    Not in the standard. But some compilers have things like this
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 5
    Last Post: 06-01-2009, 07:54 PM
  2. Regular Expression (Pattern Matching)
    By csonx_p in forum C++ Programming
    Replies: 1
    Last Post: 08-19-2008, 09:04 AM
  3. filename pattern matching
    By dwks in forum C Programming
    Replies: 11
    Last Post: 07-13-2005, 10:23 AM
  4. Pattern matching
    By GSLR in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 11-06-2003, 06:17 AM
  5. Going out of scope
    By nickname_changed in forum C++ Programming
    Replies: 9
    Last Post: 10-12-2003, 06:27 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21