CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Regular Expressions:
PERL Regular Expression for a validation form

 



vladik86
Novice

Feb 12, 2015, 10:39 AM

Post #1 of 14 (31902 views)
PERL Regular Expression for a validation form Can't Post

Hello all...
To begin with, i don't know PERL and my english is bad, so, Iíll try to explain you what i need.
I need Regular Expression that can validate a form having this syntax XXX.YYY.XYYY.X (where X are letters and Y are numbers)... so, in total, 5 letters 6 numbers and 3 dot.
I am not sure I managed to explain myself. I hope you can help me.


FishMonger
Veteran / Moderator

Feb 12, 2015, 11:08 AM

Post #2 of 14 (31901 views)
Re: [vladik86] PERL Regular Expression for a validation form [In reply to] Can't Post

/^[a-z]{3}\.\d{3}\.[a-z]]d{3}\.[a-z]$/i


vladik86
Novice

Feb 12, 2015, 11:16 AM

Post #3 of 14 (31899 views)
Re: [FishMonger] PERL Regular Expression for a validation form [In reply to] Can't Post


In Reply To
/^[a-z]{3}\.\d{3}\.[a-z]]d{3}\.[a-z]$/i


Thanks, i tried, but this expression validate only a "dot". i can put only number with 3 "dot" at the end, and the field is validated anyway


FishMonger
Veteran / Moderator

Feb 12, 2015, 11:25 AM

Post #4 of 14 (31894 views)
Re: [vladik86] PERL Regular Expression for a validation form [In reply to] Can't Post

That regex will match the exact pattern that you stated.

Does your string contain anything else besides the pattern that you need to match?

Please post the string that you're needing to validate and the code you used to do the validation.

EDIT:
Oops, I see a typo in the regex which breaks it. Change it to this:

Code
/^[a-z]{3}\.\d{3}\.[a-z]\d{3}\.[a-z]$/i



(This post was edited by FishMonger on Feb 12, 2015, 11:34 AM)


vladik86
Novice

Feb 12, 2015, 11:32 AM

Post #5 of 14 (31891 views)
Re: [FishMonger] PERL Regular Expression for a validation form [In reply to] Can't Post

There are the serial number of each operator
exsample string: CPS.045.F110.U or FAS.451.Y435.Q


FishMonger
Veteran / Moderator

Feb 12, 2015, 11:36 AM

Post #6 of 14 (31886 views)
Re: [vladik86] PERL Regular Expression for a validation form [In reply to] Can't Post

Remove the start and end anchors.

Code
/[a-z]{3}\.\d{3}\.[a-z]\d{3}\.[a-z]/i



vladik86
Novice

Feb 12, 2015, 11:50 AM

Post #7 of 14 (31884 views)
Re: [FishMonger] PERL Regular Expression for a validation form [In reply to] Can't Post

Don't work "Not a valid input"
I tried to use both uppercase and lowercase


(This post was edited by vladik86 on Feb 12, 2015, 11:51 AM)


FishMonger
Veteran / Moderator

Feb 12, 2015, 11:51 AM

Post #8 of 14 (31881 views)
Re: [vladik86] PERL Regular Expression for a validation form [In reply to] Can't Post

Post your code!!


vladik86
Novice

Feb 12, 2015, 12:06 PM

Post #9 of 14 (31877 views)
Re: [FishMonger] PERL Regular Expression for a validation form [In reply to] Can't Post

I haven't a code...it's a configuration for one joomla registration form http://puu.sh/fPxWx/8edc931bce.png


FishMonger
Veteran / Moderator

Feb 12, 2015, 12:18 PM

Post #10 of 14 (31872 views)
Re: [vladik86] PERL Regular Expression for a validation form [In reply to] Can't Post

I have no idea how your joomla registration form processes and tests the regex so I can't say why it doesn't validate.

Here's my test code and results that show that the regex DOES validate the pattern/string you specified.

Code
c:\test>type validate.pl 
#!/perl

use strict;
use warnings;

my $str = 'CPS.045.F110.U or FAS.451.Y435.Q';

if ($str =~ /[a-z]{3}\.\d{3}\.[a-z]\d{3}\.[a-z]/i) {
print "Valid Input\n";
}
else {
print "Invalid Input\n";
}


Code
c:\test>validate.pl 
Valid Input



FishMonger
Veteran / Moderator

Feb 12, 2015, 12:23 PM

Post #11 of 14 (31868 views)
Re: [vladik86] PERL Regular Expression for a validation form [In reply to] Can't Post

You might need to post your question on a forum specifically related to joomla.


vladik86
Novice

Feb 12, 2015, 12:25 PM

Post #12 of 14 (31866 views)
Re: [FishMonger] PERL Regular Expression for a validation form [In reply to] Can't Post


In Reply To
You might need to post your question on a forum specifically related to joomla.


I already tried ... they said "you have to know PERL" ... so, thank you anyway


Zhris
Enthusiast

Feb 12, 2015, 6:44 PM

Post #13 of 14 (31859 views)
Re: [vladik86] PERL Regular Expression for a validation form [In reply to] Can't Post

Based on the image you provided, assumably you won't want the / and /i at the start and end, they are Perl syntax, Joomla support should be able to confirm this. Replace the case insensitive i modifier with [a-zA-Z] character classes instead if necessary.

Chris


(This post was edited by Zhris on Feb 12, 2015, 6:57 PM)


vladik86
Novice

Feb 13, 2015, 12:48 PM

Post #14 of 14 (31836 views)
Re: [vladik86] PERL Regular Expression for a validation form [In reply to] Can't Post

Ok, now works. Probably had some problems, I reinstalled everything and now works perfectly. I wanted to thank you very much for your help on behalf of our entire association of volunteers. Thank you.

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives