473,789 Members | 2,799 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

javascript - regular expression - foreign characters

i have this function:

------------------------------------------------------------
function isAlfaNumeric(v nos,space) {
if (space==false) {
validRegExp = /^[a-zA-Z0-9]{0,}$/;
}
else {
validRegExp = /^[a-zA-Z0-9\s]{0,}$/;
}
return vnos.search(val idRegExp)
}
-------------------------------------------------------------

the function is checking if the string "vnos" contains any non-alfanumeric
characters... it works fine except it returns true if the string contains
my country characters like ž,š.....i tried to do the following

validRegExp = /^[a-zA-Z0-9žš]{0,}$/; and also

validRegExp = /^[a-zA-Z0-9\ž\š]{0,}$/; but result was the same

Does anyone know how to check for foreign characters in string using regular
expression??
Jul 20 '05
12 11449
Dr John Stockton wrote on 21 jan 2004 in comp.lang.javas cript:
But for that approach to do the original job in full, one needs to read
the entire Unicode table and decide which squashed spiders are foreign
letters and which are foreign non-letters.


A perfect solution is impossible, as long as the unicode is not redesigned
to have seperate ranges for both types. And that probably will not happen.

For an imperfect solution, say for most European languages, could be done
in a standard string along the lines of [\x01-\x1f].

Seems a perfect job for you, John, to collect suggestions from many of us
about their local lingo needs. ;-}

Would the same unicode number stand for different [letter vs nonletter]
types in different European languages ?
Or in different fonts ?

I hope not.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 20 '05 #11
JRS: In article <Xn************ ********@194.10 9.133.29>, seen in
news:comp.lang. javascript, Evertjan. <ex************ **@interxnl.net >
posted at Thu, 22 Jan 2004 08:47:39 :-
Dr John Stockton wrote on 21 jan 2004 in comp.lang.javas cript:
But for that approach to do the original job in full, one needs to read
the entire Unicode table and decide which squashed spiders are foreign
letters and which are foreign non-letters.


A perfect solution is impossible, as long as the unicode is not redesigned
to have seperate ranges for both types. And that probably will not happen.

For an imperfect solution, say for most European languages, could be done
in a standard string along the lines of [\x01-\x1f].

Seems a perfect job for you, John, to collect suggestions from many of us
about their local lingo needs. ;-}

Would the same unicode number stand for different [letter vs nonletter]
types in different European languages ?
Or in different fonts ?


Read AJF's cited page, and others, on Unicode. Look and see what is
actually in Unicode.

AIUI, the idea of Unicode is that a given character has a given number,
independently of font, size, and language; \u0041 is 'A' and \u0061 is
'a' *everywhere*. If it's not \u0061, it's not our 'a', whatever it
looks like.

In practice, though, a letter only counts as a letter if it is a letter
of the current language. In English, Nijmegen has eight letters; I
suspect it of having only seven in Dutch, only six of which are English.

--
© John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
<URL:http://jibbering.com/faq/> Jim Ley's FAQ for news:comp.lang. javascript
<URL:http://www.merlyn.demo n.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Jul 20 '05 #12
Dr John Stockton wrote on 22 jan 2004 in comp.lang.javas cript:
In practice, though, a letter only counts as a letter if it is a
letter of the current language.
I do not think o. It depends on definition, of cource. I would say a
letter in computerstrings can also be a letter in another language and
be counted as a letter. the u-umlaut [ü] is definitly a letter in
English in the sense that it is definitly not a non-letter, like
!?#%&.,.
In English, Nijmegen has eight letters; I
suspect it of having only seven in Dutch, only six of which are
English.


This is long since left concept in this time of computer generated and
sorted telephone books. The "ij", though it counts a one letter in
linguistic Dutch sense has definitely become a two letter "thing" like
the "ph".

The "ph" however, can also be pronounced in a two letter fassion in
words like:

poephark
ophaalbrug
Generaal van Opheusden ;-)

If there were a word with the ij pronounced as seperate letters, the j
should have two little points [de trema] like an umlaut. This is not
available in current fonts, I definitely presume, because the j is
usually thought as a consonant.

[The above thoughts are not tested on recent or old versions of eastern
languages, nor on Netscape]

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 20 '05 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
8213
by: Toffe | last post by:
Hi, I've got a problem with regular expressions and strings containing Swedish characters (åäö). I basically have a PHP script that highlights certain words in a text. I found the code attached below in the commented manual at php.net. It works great for all words that do not contain Swedish characters. The words that do contain åäö will not be highlighted.
1
4185
by: Kenneth McDonald | last post by:
I'm working on the 0.8 release of my 'rex' module, and would appreciate feedback, suggestions, and criticism as I work towards finalizing the API and feature sets. rex is a module intended to make regular expressions easier to create and use (and in my experience as a regular expression user, it makes them MUCH easier to create and use.) I'm still working on formal documentation, and in any case, such documentation isn't necessarily the...
5
2694
by: Sue | last post by:
After finishing up my first quarter JavaScript on 12/12/03, I decided to improve character checking on my project. In my project I only had to do very basic validation. Therefore, I only had one function to verify the name fields, age, email and gender. My question is: if I create a function for each field like the code below, what would be the best way to organize the functions and call them? Would I need one main function and place...
3
2566
by: Zach | last post by:
Hello, Please forgive if this is not the most appropriate newsgroup for this question. Unfortunately I didn't find a newsgroup specific to regular expressions. I have the following regular expression. ^(.+?) uses (?!a spoon)\.$
1
3408
by: NvrBst | last post by:
I want to use the .replace() method with the regular expression /^ %VAR % =,($|&)/. The following DOESN'T replace the "^default.aspx=,($|&)" regular expression with "": --------------------------------- myStringVar = myStringVar.replace("^" + iName + "=,($|&)", ""); --------------------------------- The following DOES replace it though: --------------------------------- var match = myStringVar.match("^" + iName + "=,($|&)");
27
1772
by: rhaazy | last post by:
I need to write some javascript that will return a date string in the form mm/dd/yyyy. The date needs to be today's date - 30 days. Is there a relatively straight forward way to do this? So far all I can find is a mess of variables for month, day, and year, and combining some date functions together, etc etc. Seems like a lot of work for what should be very simple.
0
10404
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10195
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10136
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9016
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7525
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6765
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5415
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5548
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2906
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.