First, take a look on what your input COULD (legally) be. For instance, if your date format is "yyyymmdd":
"<year_number><1-12><1-31>"
Lets first stick with that and ignore for the moment, that February doesn't have 30+ days and that there are other dates too, which are illegal by that pattern: "20050431" for instance, because April has only 30 days.
Therefore our first shot at a regular expression matching dates could be:
if this prints anything it would be a date. The regexp matches:
a number "1" or "2", followed by three numbers 0-9 (the year), followed by
a number "0" or "1", followed by a number 0-9 (the month), followed by
a "0", "1", "2" or a "3", followed by a number 0-9 (the day).
Now for the year: right now we would match anything from 1000 to 2999. Could we further eliminate unwanted years? Yes! We will (presumably) have only to deal with dates of the last decade, so we could modify our regexp part for the year to:
This matches "1 or 2" followed by "0 or 9" followed by "0 or 9" followed by any digit. This still matches i.e. "2995", but it won't match "1875" or something such.
This way one could refine the regexp to even better spread the (syntactically) legal dates from the illegal ones. Upon request I will work out a complete solution.
Below are three variables, which I want to pass into variable RESULT1
username1=userid
poihostname1=dellsys.com
port1=8080
How can I pass these variables into below code...
RESULT1=$((ssh -n username1@poihostname1 time /usr/sfw/bin/wget --user=sam --password=123 -O /dev/null -q... (4 Replies)
Sometimes it is handy to protect long scripts in C++.
The following syntax works fine for simple commands:
#define SHELLSCRIPT1 "\
#/bin/bash \n\
echo \"hello\" \n\
"
int main ()
{
cout <<system(SHELLSCRIPT1);
return 0;
}
Unfortunately for there are problems for:
1d arrays:... (10 Replies)
Hi All,
i have a requirement where i have to run a script with at least 25 arguements and position of arguements can also change. the unapropriate way is like below. can we achieve this in more good and precise way??
#!/bin/ksh
##script is sample.ksh
age=$1
gender=$2
class=$3
.
.
.... (3 Replies)
Hi, (i'm sorry for my english)
I'm a problem on boot sco unix 5.0.5 open server.
this stop at "Checking protected password and checking subsystem databases"
(See this image )
I'm try this:
1) http://www.digipedia.pl/usenet/thread/50/37093/#post37094
2) SCO: SCO Unix - Server hangs... (9 Replies)
i'm trying to make a script to simply add numbers together
for example i have a file script file called add
add 1 2 3 4 5
15
however i want the user to put at least 3 numbers so i did this
if
then
echo "please enter more than two numbers"
exit 1
fi
but it's telling me i have... (3 Replies)
hi
i am writing a hangman script and am having trouble checking the correct letters against the word
i need the script to compare the word against the letters guessed that are correct so once all the letters within the word have been guessed it will alow me to create a wining senario
eg
... (3 Replies)
Hello everybody,
I am having problem in converting byte array variables to Hexa String variables for Linux. I have done, converting byte array variables to Hexa String variables for Windows but same function doesn't work for linux. Is there any difference in OS ? The code for Windows is given... (2 Replies)
Hello,
FIRST QUESTION:
I am writing a script in which a query is taken at the beginning of the script to be later used at the end. In the query, variables are generated from a loop, and I would like to assign the variable NAME (not value) with an appended 1, 2, 3, 4.....n. The number of... (2 Replies)
I have a script that I'm trying to shorten (below) by removing repetitive code.
if ]
then
commodity_ndm_done=Y
fi
if ]
then
customer_ndm_done=Y
fi
if ]
then
department_ndm_done=Y
fi
if ]
then
division_ndm_done=Y
fi (3 Replies)