Syntax checking of user input

From: mike (s99999999s2003_at_yahoo.com)
Date: 11/30/03


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



Relevant Pages

  • Re: Efficient regular expression pattern ?
    ... "pattern". ... SPAM detection rules act as a filter, and if I'm not mistaken, you want to ... what I would do is to identify which regular expressions filter the most ...
    (microsoft.public.dotnet.framework)
  • Re: renattach 1.2.0rc1 - Filter that renames/deletes dangerous email attachments
    ... > procmail capable Mail Transport Agent? ... difference in the processing overhead between compiled C, and a huge perl ... the intent of the filter is different. ... Renattach has been used by the Medical University of South Carolina and ...
    (comp.os.linux.security)
  • Re: renattach 1.2.0rc1 - Filter that renames/deletes dangerous email attachments
    ... > procmail capable Mail Transport Agent? ... difference in the processing overhead between compiled C, and a huge perl ... the intent of the filter is different. ... Renattach has been used by the Medical University of South Carolina and ...
    (comp.security.unix)
  • Re: filtering DataGrid on the fly
    ... funcionality to allow user input some text on the page to filter the data ... the response content back to client browser and the client browser display ... And if you want to filter data, ... Microsoft MSDN Online Support Lead ...
    (microsoft.public.inetserver.asp.db)
  • Re: Efficient regular expression pattern ?
    ... The first "client app" will be a proxy system that will kick this http ... request and replace by a warning message (so even if the user try to display ... Email filter is not planned now, but it should be a great idea to capitalize ... what I would do is to identify which regular expressions filter the ...
    (microsoft.public.dotnet.framework)