Thread: Simple regular expression to find word in a string?

  1. #1
    Registered User
    Join Date
    Sep 2008
    Posts
    16

    Simple regular expression to find word in a string?

    Hey,

    I have assignment to do for class and the beginning part is to design a regular expression as follows:

    Over the alphabet Σ of ASCII characters, define a Regular Expression that describes a search for the string “coconut”. You can use the expression Σ* to denote an arbitrary sequence of characters in Σ.

    This makes me think its appropriate to do E*(coconut)E*. Any arbitrary characters, followed by "coconut", followed by any arbitrary characters? Am I totally missing something or is this correct?

    Thanks for any advice.

    BC

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Looks like a plan to me. You can try to make it less readable, I suppose. And it might be based on the "format" you use for regexes; do you necessarily need the Σ*?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Find whole word in string, case insensetive.
    By IM back! in forum C++ Programming
    Replies: 12
    Last Post: 03-19-2010, 10:06 PM
  2. Inheritance Hierarchy for a Package class
    By twickre in forum C++ Programming
    Replies: 7
    Last Post: 12-08-2007, 04:13 PM
  3. Linked List Help
    By CJ7Mudrover in forum C Programming
    Replies: 9
    Last Post: 03-10-2004, 10:33 PM
  4. Classes inheretance problem...
    By NANO in forum C++ Programming
    Replies: 12
    Last Post: 12-09-2002, 03:23 PM
  5. length of string etc.
    By Peachy in forum C Programming
    Replies: 5
    Last Post: 09-27-2001, 12:04 PM