Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Regular Expression problem
Old 01-27-2009, 11:12 AM Regular Expression problem
frofi's Avatar
Extreme Talker

Posts: 236
Location: London
Trades: 0
Hello everyone,


I wonder if you could help me. I'm trying to create a regular expression for my input boxes. This is my regex function:
PHP Code:
function validname($name){
 return 
preg_match("/^[+-a-z0-9\s_]*$/i"stripslashes($_POST['name']));

I only want to allow alphanumerical characters and “+-_”(plus, minus and underscore). I thought I had it all figured out but then I realised my regex also allows “. , ; ` [ ] < > ? / ” for some reason.


What am I doing wrong?
__________________
THE FORCE is with me at last! All I need now is some TALKUPATION ;)
frofi is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 01-27-2009, 11:26 AM Re: Regular Expression problem
Insensus's Avatar
Ultra Talker

Posts: 487
Name: Mark Stegeman
Location: Netherlands, Europe
Trades: 0
Try this for a pattern:
/^[\+\-a-z0-9\s_]*$/i
__________________
<?php ($helpfull>0)?$talkupation++ : '';?>
Insensus is offline
Reply With Quote
View Public Profile
 
Old 01-27-2009, 12:25 PM Re: Regular Expression problem
frofi's Avatar
Extreme Talker

Posts: 236
Location: London
Trades: 0
Quote:
Originally Posted by Insensus View Post
Try this for a pattern:
/^[\+\-a-z0-9\s_]*$/i
Thanks, that worked like a charm! Now I even understand why. Talkupation added.
__________________
THE FORCE is with me at last! All I need now is some TALKUPATION ;)
frofi is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Regular Expression problem
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.11849 seconds with 12 queries