Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > Pro PHP
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 1st, 2004, 02:28 PM
Authorized User
 
Join Date: Jun 2003
Location: , , .
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
Reply With Quote
  #2 (permalink)  
Old November 1st, 2004, 05:21 PM
Friend of Wrox
 
Join Date: Nov 2003
Location: , , .
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.
Reply With Quote
  #3 (permalink)  
Old November 3rd, 2004, 02:27 PM
Authorized User
 
Join Date: Jun 2003
Location: , , .
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
Reply With Quote
  #4 (permalink)  
Old November 3rd, 2004, 04:11 PM
richard.york's Avatar
Wrox Author
Points: 5,506, Level: 31
Points: 5,506, Level: 31 Points: 5,506, Level: 31 Points: 5,506, Level: 31
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Camby, IN, USA.
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
Reply With Quote
  #5 (permalink)  
Old November 4th, 2004, 08:15 PM
Friend of Wrox
 
Join Date: Nov 2003
Location: , , .
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!
Reply With Quote
  #6 (permalink)  
Old November 5th, 2004, 09:35 AM
Authorized User
 
Join Date: Jun 2003
Location: , , .
Posts: 43
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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

dung
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 11:37 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.