Hello guys, i have problem with regular expression , I have search box, I tried to enter (',#,$,%,^,&,"star",@,!,") or any other special charachters, it give me the whole database items, so i want to limit the enrty to only letters [a-z] numbers [0-9] and arabic charachters [ا-ي]
or to be clear any letter is allowed except for special charachters
I used this but it not allowed english
if(preg_match('/[^\w\d_ -]/si', $search)) {
echo " You entered not allowed letters";
exit();
}
and if I put !preg_match the arabic will not be allowed, what should I put in regexp ? BTW spaces are allowed
3
Contributors
12
Replies
3 Days
Discussion Span
6 Months Ago
Last Updated
13
Views
Question Answered
Related Article:Html entities & html special chars
is a solved PHP discussion thread by DaveyMoyes that has 6 replies, was last updated 1 year ago and has been tagged with the keywords: chars, entities, html, php, special.
I think you didn't understand what I need, I need to detect only special charachter, I don't care what user input language the important thing I don't need speciaql characters
I need an expression to detect those characters and show refuse msg
<?php
$string = "I dont need specia'l @charachters # " // anything , any language
if (preg_match([//regexp to detect special characters],$string) {
$msg = "not allowed";
else {
// do anything I want ( search - register - mail )
}
?>
thanks for reply, but when tried the code you gave me, it trimmed all Arabic characters, which I need, I need to trim only special charachters (# ? % $ £ )
I read the post by @pritaeas at first I didn't ubderstand , but now I relized
maybe my php version is the problem
My PHP version is 5.2.6, now am downloading the latest version of php and I'll try
Thanks, for reply, I dont know what the wrong, I've installed WAMP and it give me errors not found in appserve, and it ruin my project, I'll back to my version 5.2.6 and keep working untill this problem resolved,SOLVED (Nearly)