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