If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Delphi, C etc > How to captured regular expression + character + numeric from command line processing

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-19-03, 13:00
bh_perl bh_perl is offline
Registered User
 
Join Date: Oct 2003
Posts: 3
How to captured regular expression + character + numeric from command line processing

Hi....

I have some problem here....
How to captured numeric and character input values from command line processing likes * ^ ? [ ] and so on . Example of command line processing :

getopt -l ^0123?(4546|7890) file.txt

NOTE:
It's should be working like regular expression to grep any entire values from the input file....

Referring to my program below, it is only working on integer values. As example :

getopt -l 12345 file.txt
==> length are 12345

getopt -l ^12345 file.txt
==> bad length

I've tried a few method but it's maintain on failed level.

Otherwise, Could I know how the regular expression works in C language ? ... this is for my next processsing...

Pleased give some example as my referrence...

Code:
main (argc, argv)
        int argc;
        char *argv[];
{
        extern char *optarg;
        extern int  optind;
        int         sopt = 0, jopt = 0, error = 0, c;
        long        length = 0;

        while ( ( c = getopt(argc, argv, "sjl:") ) != EOF )
                switch (c) {
                        case 's':
                                sopt = 1;
                                break;
                        case 'j':
                                jopt = 1;
                                break;
                        case 'l':
                                length = atol (optarg);
                                printf ("length are %d\n", length);

                                if ( length <= 0 ) {
                                        printf ("bad length\n");
                                        error = 1;
                                }
                                break;
                        case '?':
                                error = 1;
                                break;
                        default:
                                printf ("bug\n");
                                exit (1);
                }

        if (error) {
                printf ("Usage: my programme [-s] [-j] [-i len] [file...]\n");
                exit (2);
        }
}

TQVM,
bh
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On