M
mike
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
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