Regex Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - MoreRegex Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 30th, 2012, 10:11 AM
rreimche rreimche is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2012
Posts: 1 rreimche User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 m 33 sec
Reputation Power: 0
Error in the expression?

This script should check if there are any "bad" characters, i.e. if an attack is being commenced:



PHP Code:
 $string_exp "/^[- ,.A-Za-zА-Яа-я0-9]+$/";
if(!
preg_match($string_exp,$tour_title)) { 
    
$error_message .= '<li>Bad data in one the "tour_desc" field.</li>'
  } 


Then, if $error_message contains anything, an error message should be displayed instead of sending an email.

I suppose that is the string contains only latin symbols, cyrillic symbols, numbers, comma, dot, space or "-", the check should be OK and the email should be sent. But in reality it seems so that the test gives an error depending on what cyrillic symbols are there in the string.

I tried some examples:

Syntax: [ Download ] [ Hide ] [ Select ]
abvgd
абвгд
Абвгда
АбрикосыАпельсины
Абрикосы
Абр


and some of them work and some don't.

Could anybody point me at the problem please?

Reply With Quote
  #2  
Old June 30th, 2012, 03:16 PM
spacebar208's Avatar
spacebar208 spacebar208 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2012
Location: spaceBAR Central
Posts: 203 spacebar208 User rank is Sergeant Major (2000 - 5000 Reputation Level)spacebar208 User rank is Sergeant Major (2000 - 5000 Reputation Level)spacebar208 User rank is Sergeant Major (2000 - 5000 Reputation Level)spacebar208 User rank is Sergeant Major (2000 - 5000 Reputation Level)spacebar208 User rank is Sergeant Major (2000 - 5000 Reputation Level)spacebar208 User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 2 Days 16 h 10 sec
Reputation Power: 41
This worked in my test:
Code:
if (preg_match('/^[- ,.A-Za-zА-Яа-я0-9]+$/', $test)) {
  #matches
} else {
  #does not match
}

Matches these:
abvgd
абвгд
Абвгда
АбрикосыАпельсины
Абрикосы
Абр

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreRegex Programming > Error in the expression?

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap