Go Back   CodingForums.com > :: Server side development > Perl/ CGI

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-09-2010, 06:18 AM   PM User | #1
bazz
Master Coder

 
Join Date: Apr 2003
Location: in my house
Posts: 5,211
Thanks: 39
Thanked 201 Times in 197 Posts
bazz will become famous soon enoughbazz will become famous soon enough
regex to prevent x0 insertions

Hi,

I thought I had this wokring but it seems not. Was trying to enter the word 'exceptional' but it was rejected, likely due to the x. It's the only thing I can think of.

So here is my regex. How can the /x0/ part be improved.

Code:
  if ( $title =~ /^[^\w\d\s\ \'\!\?\£\$\&\(\)\-\+\;\:\@\,\.]+$/ || $title =~ /[x0]/ || $title eq '' ) {
bazz
__________________
"The day you stop learning is the day you become obsolete"! - my late Dad.

Why do some people say "I don't know for sure"? If they don't know for sure then, they don't know!
Useful MySQL resource
Useful MySQL link
bazz is offline   Reply With Quote
Old 03-09-2010, 01:47 PM   PM User | #2
FishMonger
Super Moderator


 
Join Date: May 2005
Location: Southern tip of Silicon Valley
Posts: 2,757
Thanks: 2
Thanked 149 Times in 144 Posts
FishMonger will become famous soon enoughFishMonger will become famous soon enough
What makes you think it was rejected due to the x?

Why are you needlessly escaping all those characters in the character class?

What was the exact error message when it was rejected?

Please post a more complete section of the related code?
FishMonger is offline   Reply With Quote
Old 03-09-2010, 05:52 PM   PM User | #3
bazz
Master Coder

 
Join Date: Apr 2003
Location: in my house
Posts: 5,211
Thanks: 39
Thanked 201 Times in 197 Posts
bazz will become famous soon enoughbazz will become famous soon enough
I'll give a better reply later but, the reason I thought it was the x was because; when I removed this from the conditional

Code:
$title =~ /[x0]/
The script didn't baulk and instead worked fine. There was no '0' (zero) in the string so I assumed it was the 'x'.

I'll tidy it up and see if that helps.


bazz
__________________
"The day you stop learning is the day you become obsolete"! - my late Dad.

Why do some people say "I don't know for sure"? If they don't know for sure then, they don't know!
Useful MySQL resource
Useful MySQL link
bazz is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

Forum Jump


All times are GMT +1. The time now is 07:04 AM.


Advertisement
Log in to turn off these ads.