Sponsored Content
Top Forums Shell Programming and Scripting Perl Regular Expression - Whitelist Post 89983 by mh53j_fe on Thursday 17th of November 2005 09:59:56 AM
Old 11-17-2005
Power Perl Regular Expression - Whitelist

I am creating a whitelist for User Input Validation. Here is a code snippet that allows alphanumeric and forward slash (/).
if ( $variable =~ /^[a-zA-Z0-9\/]*$/ ) #allow alphanumeric and fwd slash
{
$returnValue = 'good data';
}
else
{
$returnValue = 'Bad Data';
}

The problem that I am having is that when I pass a value such as
FWD/RWD, the code returns the value 'Bad Data'. What am I doing wrong? Why doesn't the variable recognize the forward slash in the regular expression?

Thanks in advance for your help.
Dave
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Regular expression help in perl

Hi all, I am trying to match a multi line string and return the matching string in one line. Here is the perl code that I wrote: #!/usr/bin/perl my $str='<title>My title</title>'; if ($str =~ /(<title>)(+)(<\/title>)/ ){ print "$2\n"; } It returns : My title I want the... (3 Replies)
Discussion started by: sdubey
3 Replies

2. Shell Programming and Scripting

perl regular expression

letz say that my file has 7 records with only one field. So my file has: 11111111 000000000000000 1111 aaaabbbccc 1111111222000000 aaaaaaaa zz All i need is: 1. when the field has a repetition of the same instance(a-z or 0-9), i would consideer it to be invalid.... (1 Reply)
Discussion started by: helengoldman
1 Replies

3. Shell Programming and Scripting

perl regular expression

Dear all, I have a simple issue on a perl regular expression. I want to get the characters in red from the next lines : POWER_key LEFT_key RIGHT_key OK_key DOWN_key and so on... Thanks in advance for reply. Ludo (1 Reply)
Discussion started by: lsaas
1 Replies

4. Shell Programming and Scripting

Regular expression in Perl

Hi, I need and expression for a word like abc_xyz_ykklm The expresion should indicate that the word starts with abc and end with ykklm but does not contain xyz string in the middle. Example: abc_tmn_ykklm is ok and abc_xyz_ykklm is not Ok. Please help. Regards. (1 Reply)
Discussion started by: asth
1 Replies

5. Shell Programming and Scripting

Perl Regular Expression

Hello, I am trying to use perl LWP module to read and get a specfic URL page. The issue is that the URL ends with the data and time and time is not consistent it changes all the time. if anyone could help me how to write a regular expressin that would work in the LWP::UserAgent get function to... (0 Replies)
Discussion started by: bataf
0 Replies

6. Shell Programming and Scripting

Perl regular expression and %

Could you help me with this please. This regular expression seems to match for the wrong input #!/usr/bin/perl my $inputtext = "W1a$%XXX"; if($inputtext =~ m/+X+/) { print "matches\n"; } The problem seems to be %. if inputtext is W1a$XXX, the regex doesnot match.... (5 Replies)
Discussion started by: suppandi7
5 Replies

7. Shell Programming and Scripting

Hidden Characters in Regular Expression Matching Perl - Perl Newbie

I am completely new to perl programming. My father is helping me learn said programming language. However, I am stuck on one of the assignments he has given me, and I can't find very much help with it via google, either because I have a tiny attention span, or because I can be very very dense. ... (4 Replies)
Discussion started by: kittyluva2
4 Replies

8. Shell Programming and Scripting

Perl regular expression help!

Hi I am doing something basic like... if ($stringvariable =~ /have not typed/) I have a little problem because the 'not' in the expression gets highlighted as a kind of a '!'..what am I supposed to do in this situation? Thank you ---------- Post updated at 03:24 PM ----------... (1 Reply)
Discussion started by: vas28r13
1 Replies

9. Programming

Perl: How to read from a file, do regular expression and then replace the found regular expression

Hi all, How am I read a file, find the match regular expression and overwrite to the same files. open DESTINATION_FILE, "<tmptravl.dat" or die "tmptravl.dat"; open NEW_DESTINATION_FILE, ">new_tmptravl.dat" or die "new_tmptravl.dat"; while (<DESTINATION_FILE>) { # print... (1 Reply)
Discussion started by: jessy83
1 Replies

10. Shell Programming and Scripting

Perl regular expression

Hi , I have the below array my @actionText = ("delivered to governor on 21/23/3345" , "deliver jllj" , "ram 2345/43"); When i am trying to grep the contents of array and if mathced substituting with the digitis or some date format from the element like below my @action = grep { $_ =~... (7 Replies)
Discussion started by: ragilla
7 Replies
Validation::Class::Exporter(3pm)			User Contributed Perl Documentation			  Validation::Class::Exporter(3pm)

NAME
Validation::Class::Exporter - Simple Exporter for Validation::Class Classes VERSION
version 7.70 SYNOPSIS
package MyApp::Class; use Validation::Class; use Validation::Class::Exporter; Validation::Class::Exporter->apply_spec( routines => ['thing'], # export routines as is settings => [ ... ] # passed to the "load" method, see Validation::Class ); has foo => 0; bld sub { shift->foo(1); }; sub thing { my $args = pop; my $class = shift || caller; # routine as a keyword $class->{config}->{THING} = [$args]; }; package MyApp::Example; use MyApp::Class; thing ['this' => 'that']; package main; my $eg = MyApp::Example->new; # we have lift-off!!! DESCRIPTION
This module (while experimental) encapsulates the exporting of keywords and routines. It applies the Validation::Class framework along with any keyword routines and/or sub-routines specified with the apply_spec() method. It does this by simply by copying the spec into the calling class. To simplify writing exporter modules, "Validation::Class::Exporter" also imports "strict" and "warnings" into your exporter module, as well as into modules that use it. METHODS
apply_spec When you call this method, "Validation::Class::Exporter" builds a custom "import" method on the calling class. The "import" method will export the functions you specify, and can also automatically export "Validation::Class" making the calling class a Validation::Class derived class. This method accepts the following parameters: o routines => [ ... ] This list of function names only will be exported into the calling class exactly as is, the functions can be used traditionally or as keywords so their parameter handling should be configured accordingly. o settings => [ ... ] This list of key/value pair will be passed to the load method imported from "Validation::Class::load" and will be applied on the calling class. This approach affords you some trickery in that you can utilize the load method to apply the current class' configuration to the calling class' configuration, etc. AUTHOR
Al Newkirk <anewkirk@ana.io> COPYRIGHT AND LICENSE
This software is copyright (c) 2011 by Al Newkirk. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. perl v5.14.2 2012-06-28 Validation::Class::Exporter(3pm)
All times are GMT -4. The time now is 03:44 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy