473,387 Members | 1,724 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

preg_match matching non english char

preg_match is not kicking out non English characters from a string.

Expand|Select|Wrap|Line Numbers
  1. ( preg_match("/^[a-zA-Z0-9]+$/", $title)
For example it will say that sting has all English chars.

阿达网球大赛

Running PHP from cmd line in Win system setup.
Sep 30 '10 #1
2 2697
Markus
6,050 Expert 4TB
That should be: /[^a-zA-Z0-9]/

Matches anything *other than* alphanumeric characters.
Oct 1 '10 #2
kovik
1,044 Expert 1GB
Note that preg_match will not alter the subject string, and thus will not "kick out" any characters.

Also, I think that "\w" may be more appropriate than "[A-Za-z0-9]" since it grabs a little bit more than just alphanumeric characters.
Oct 4 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: fartsniff | last post by:
hello all, here is a preg_match routine that i am using. basically, $image is set in some code above, and it can be either st-1.gif or sb-1.gif (actually it randomly picks them from about 100...
3
by: Martin Lucas-Smith | last post by:
Is there some way of using ereg to detect when certain filename extensions are supplied and to return false if so, WITHOUT using the ! operator before ereg () ? I have an API that allows as an...
10
by: aaron | last post by:
I need some help with validating an email address. Right now, I am doing this: function sys_is_valid_email ($s) { if (preg_match ("/^.+@.+\..+$/", $s)) { return 1; } else { return 0; } }
4
by: Nel | last post by:
Please can someone help me with this before I explode!!! (no pun intended) <?php // EXAMPLE 1 $text = "This is Driving me mad"; $check = "Driving"; $ss = "({0,30}".$check."{0,30})";...
37
by: Debajit Adhikary | last post by:
Now I know (from Stroustrup's site) that "char" is pronounced "tchar" and not "kar". Does the same hold true largely in the C world?
3
by: Weiping | last post by:
Hi, while upgrade to 8.0 (beta3) we got some problem: we have a database which encoding is UNICODE, when we do queries like: select upper(''); --select some multibyte character, then...
2
by: JanDoggen | last post by:
function vldLicense($lic) { echo "called with lic: ". $lic . "<br>"; echo preg_match('', $lic) . "<br>"; if (preg_match('{4}-{4}-{4}-{4}', $lic) == 0) return false; return true; } gives me:
13
by: chadsspameateremail | last post by:
I might have found a problem with how preg_match works though I'm not sure. Lets say you have a regular expression that you want to match a string of numbers. You might write the code like this:...
3
by: Gandalf | last post by:
I works with python 2.5 on windows, And I use sqlite3 Now, I have problem searching string in Hebrew in my database I have table called "test" with field num and test firs row i insert "1"...
8
by: Thomas Mlynarczyk | last post by:
Hello, I want to split a given string into tokens which are defined by regexes: // example tokens - a bit more complex in real $tokens = array( 'NUMBER' ='~^\d+~', 'NAME' ='~^+~', 'ANY' ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.