Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Pro PHP
|
Pro PHP Advanced PHP coding discussions. Beginning-level questions will be redirected to the Beginning PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 1st, 2004, 02:28 PM
Authorized User
 
Join Date: Jun 2003
Posts: 43
Thanks: 0
Thanked 0 Times in 0 Posts
Default regular expression/general practice

hello to all,

I have a two different questions that i would greatly appreciate your assistance on...

I am trying to control a input type field via php using regular expression, but unfortunately i don't know where to start.
I want the field to contain a V(as the first character) and numbers for the remainder of the field. How do I utilize the regular expression or write the regular expression to accomplish that task?

eg. V12345, V45464, V94948

Moreoever, I've asked this particular question before and received a good answer, but and still unsure of practices. Would it be a good practice to adapt by seprating your sql statements and functions from your client side scripts and pages? What is the general practice in the industry for security reasons and/or performance reasons regarding sql scripts in php client side pages?

I hope that made sense, and I am looking forward to hearing back from everyone...

Dungey
 
Old November 1st, 2004, 05:21 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Hey, I'm a bit new to regular expressions, but I believe this is the pattern you want:

V[0-9]{5}

HTH

-Snib
Where will you be in 100 years?
Try new FreshView 0.2!
The two rules: 1) I am always wrong. 2) If I'm right, refer to rule number 1.
 
Old November 3rd, 2004, 02:27 PM
Authorized User
 
Join Date: Jun 2003
Posts: 43
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks snibs for the help. I have a couple more questions if you don't mind. Is the "{5}" for only 5 characters after the V are allowed? and also how do i allow lowercase v in the expression cause it won't except a lower case v when I try it.


thanks...dungey
 
Old November 3rd, 2004, 04:11 PM
richard.york's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

The best place to look for this sort of thing is in the PHP manual. Assuming you're using Perl-compatible regular expressions (PCRE).

http://www.php.net/pcre
http://www.php.net/manual/en/referen...ern.syntax.php

HTH!

Regards,
Rich

--
[http://www.smilingsouls.net]
[http://pear.php.net/Mail_IMAP] A PHP/C-Client/PEAR solution for webmail
 
Old November 4th, 2004, 08:15 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Amended:

(v|V)[0-9]{5}

Yes, the {5} says that there will be five numbers from 0-9.

-Snib
Where will you be in 100 years?
Try new FreshView 0.2!
 
Old November 5th, 2004, 09:35 AM
Authorized User
 
Join Date: Jun 2003
Posts: 43
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you all for assisting... It works nicely...

dung





Similar Threads
Thread Thread Starter Forum Replies Last Post
Regular Expression in C++ praveenholal C++ Programming 1 March 4th, 2007 01:18 AM
REGULAR EXPRESSION pallone Javascript How-To 0 September 5th, 2006 06:52 AM
Regular Expression DARSIN General .NET 2 November 9th, 2004 08:30 AM
Regular Expression Help Hadware .NET Web Services 3 November 4th, 2003 10:51 AM
help in regular expression diby Beginning PHP 1 September 17th, 2003 12:25 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.