Syntax checking of user input
From: mike (s99999999s2003_at_yahoo.com)
Date: 11/30/03
- Next message: Gregory Toomey: "Re: Syntax checking of user input"
- Previous message: Sam Holden: "Re: trouble with DBI/CGI"
- Next in thread: Gregory Toomey: "Re: Syntax checking of user input"
- Reply: Gregory Toomey: "Re: Syntax checking of user input"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 29 Nov 2003 22:55:16 -0800
hi
i need to get user input and filter the input like this :
pass(func1) (OR|AND) pass(anyinput) (OR|AND) pass(func)
the conditions to be met are
1) check for any number of the word "pass"
2) only OR and AND can be used. Therefore the following are valid:
- pass(anywords) AND pass(anywords2) OR pass(anyany)
- pass(anywords) AND pass(anywords3)
- pass(anywords)
3) any number of words and digits can be inside the parenthesis
eg pass(abcd) or pass(1d2ad) etc
4) cannot have a "runaway" OR or AND, like this
- pass(asdfa) OR
an initial attempt is
my $input = <STDIN>;
chomp($input);
if ( $input =~ /(OR|AND)$/ )
{ failed() ; }
elsif ( $input =~ /^pass\((.*)\)$/ )
{ dosomething(); }
but i am stuck with this input condition whereby user keys in many
"pass" ,
something like this:
pass(args1) OR pass(args2) AND pass(args3) OR pass(args4) AND
pass(args5) OR pass(1234) AND pass(args6) OR pass(aafs)
in a situation like this, how can i perform input validation using
regular expressions in perl?
thanks
- Next message: Gregory Toomey: "Re: Syntax checking of user input"
- Previous message: Sam Holden: "Re: trouble with DBI/CGI"
- Next in thread: Gregory Toomey: "Re: Syntax checking of user input"
- Reply: Gregory Toomey: "Re: Syntax checking of user input"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|