Thread: How is regex used?

  1. #1
    Registered User Strider's Avatar
    Join Date
    Aug 2001
    Posts
    149

    How is regex used?

    I have done some work with regular expressions using regex in Unix, but the format for regex in Windows is different. I have downloaded the gnu Win32 version of regex and would like to learn how to use it in either Visual C++ 6.0 or Dev-C++ 4.0.1. The documentation only breifly covers the functionality and does not provide any useful examples.

    What I am trying to do is read a line from a file into a string and then parse the desired items based on a '|' delimeter. Here is a portion of what I am currently using to parse through the string:
    Code:
    /* **edit** sorry - forgot to add that I typedef some things
        PC = char *
        CH = char
        UI = unsigned int
    */
        if (pcLine[0] != '|')
        {
            // skip lines that don't start with a pipe
            return;
        }
    	
        // skip over the initial delimiter
        PC pcCursor(pcLine + 1);
    
        CH chTemp[255] = "";
    
        // start with the name field
        UI uiCursor = 0;
        while (*(pcCursor) != '|')
            chTemp[uiCursor++] = *(pcCursor++);
    This is just a small portion of it. I would like to try doing the same thing using regcomp() or regexec(), but I still don't understand how I use the regex_t structure with these functions to fill one string with the data pulled out of another. Useful examples or documentation that anyone might be able to pass on would be much appreciated.

    Thanks,
    David
    Last edited by Strider; 12-14-2001 at 09:01 AM.
    One Ring to rule them all, One Ring to find them,
    One Ring to bring them all and in the darkness bind them
    In the Land of Mordor where the Shadows lie.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problems with Boost Regex in Eclipse CDT
    By Hunter0000 in forum C++ Programming
    Replies: 4
    Last Post: 01-13-2010, 12:22 PM
  2. regex help
    By Jaqui in forum Tech Board
    Replies: 8
    Last Post: 10-14-2006, 03:53 PM
  3. Regex for path parsing
    By AngKar in forum C# Programming
    Replies: 4
    Last Post: 06-09-2006, 12:30 PM
  4. My own regex...............class?
    By misplaced in forum C++ Programming
    Replies: 5
    Last Post: 04-08-2005, 09:18 AM
  5. <regex.h> regex syntax in C
    By battersausage in forum C Programming
    Replies: 7
    Last Post: 03-24-2004, 01:35 PM