Hi,
I can't get the characters with accents in a regex. This is my code :
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
var MyText1 = "éléphant1" ;
var MyText2 = "elephant1" ;
var MyReg = /^[\w]+$/ ;
if(MyReg.test(M yText1))
alert(MyText1 + " is OK") ;
else
alert(MyText1 + " is not valid") ;
if(MyReg.test(M yText2))
alert(MyText2 + " is OK") ;
else
alert(MyText2 + " is not valid") ;
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Here's what I get :
éléphant1 is not valid
elephant1 is OK
I'd like éléphant1 to be OK, but I can't.
Can you help me ?
Thanks in advance,
Albert 9 19545
albert wrote:
I can't get the characters with accents in a regex. This is my code :
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
var MyText1 = "�l�pha nt1" ;
var MyText2 = "elephant1" ;
var MyReg = /^[\w]+$/ ;
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Here's what I get :
�l�phant1 is not valid
elephant1 is OK
I'd like �l�phant1 to be OK, but I can't.
Can you help me ?
ECMA262 15.10.2.12 defines \w as being equivalent to the character class
[0-1A-za-z_]. The w suggests word, but that is deceptive. Support for
internationaliz ation in JavaScript's RegExp is virtually nonexistent.
You need to define your own character class. http://javascript.crockford.com/
ECMA262 15.10.2.12 defines \w as being equivalent to the character class
[0-1A-za-z_]. The w suggests word, but that is deceptive. Support for
internationaliz ation in JavaScript's RegExp is virtually nonexistent.
You need to define your own character class.
How can I do so ?
albert
albert wrote on 22 sep 2007 in comp.lang.javas cript:
>ECMA262 15.10.2.12 defines \w as being equivalent to the character class [0-1A-za-z_]. The w suggests word, but that is deceptive. Support for internationaliz ation in JavaScript's RegExp is virtually nonexistent.
You need to define your own character class.
How can I do so ?
var MyReg = /^[\wáéíóäëiöúàèìì ù]+$/i;
Depending on your local requirements.
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
var MyReg = /^[\wáéíóäëiöúàèìì ù]+$/i;
>
Depending on your local requirements.
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
I've got french... that's no pb.
But I also have arabic & hebrew, this is more difficult.
albert
albert wrote on 22 sep 2007 in comp.lang.javas cript:
>var MyReg = /^[\wáéíóäëiöúàèìì ù]+$/i;
Depending on your local requirements.
[please do not quote signatures on usenet. removed]
>
I've got french... that's no pb.
pb? [please no sms-language on usenet]
But I also have arabic & hebrew, this is more difficult.
Why should it be easy?
Javascript accommodates unicode.
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
In comp.lang.javas cript message <S_************ ******@newssvr1 3.news.pro
digy.net>, Sat, 22 Sep 2007 13:44:18, Douglas Crockford
<no****@sbcglob al.netposted:
> ECMA262 15.10.2.12 defines \w as being equivalent to the character class [0-1A-za-z_]. The w suggests word, but that is deceptive. Support for internationaliz ation in JavaScript's RegExp is virtually nonexistent.
<URL:http://www.merlyn.demo n.co.uk/humourous.htm#F redHoyleadvises <G>
:-
Fred Hoyle (1915-2001) :-
"'Dam’ good idea. Always force foreigner to learn English.'"
Alexis Ivan Alexandrov, in "The Black Cloud", Chap. 10, para 4.
--
(c) John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v6.05 MIME.
Web <URL:http://www.merlyn.demo n.co.uk/- FAQqish topics, acronyms & links;
Astro stuff via astron-1.htm, gravity0.htm ; quotings.htm, pascal.htm, etc.
No Encoding. Quotes before replies. Snip well. Write clearly. Don't Mail News.
>I've got french... that's no pb.
>
pb? [please no sms-language on usenet]
pb = problem (sorry, I thought it was obvious).
>
>But I also have arabic & hebrew, this is more difficult.
Why should it be easy?
I've never said it should be easy. Don't waste time to answer here...
>
Javascript accommodates unicode.
Well I tried a simple word in Arabic with the following regex :
^[\w]+$
still, the "test" function always returned false. Do you have any good
working example about it ?
thx, oops, soory I meant "Thanks" ;-)
albert
albert wrote on 23 sep 2007 in comp.lang.javas cript:
>>I've got french... that's no pb.
pb? [please no sms-language on usenet]
pb = problem (sorry, I thought it was obvious).
Not to me. Usenet has it's own limited set of abbreviations.
If any Pb perhaps would be lead.
>>But I also have arabic & hebrew, this is more difficult.
Why should it be easy?
I've never said it should be easy. Don't waste time to answer here...
You are the OP, so ...
>Javascript accommodates unicode.
Well I tried a simple word in Arabic with the following regex :
^[\w]+$
Would you allow for figures 0-9?
Otherwise this is better for simple Latin chars:
/^[a-z]+$/i
still, the "test" function always returned false.
I showed you how to do that with accents,
did you understand the regex?
Why would Arabic characters match
where accented characters do not?
Do you have any good
working example about it ?
I am not into working examples, but will gve you a hint.
Arabic should work the same as accented ones:
/^[a-z\u0600-\u06ff]+$/
[ http://unicode.org/charts/PDF/U0600.pdf]
Not knowing Arabic I cannot test that.
thx, oops, soory I meant "Thanks" ;-)
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
You are the OP, so ...
Now it's my turn :-)
What does OP mean ?
>> Well I tried a simple word in Arabic with the following regex :
^[\w]+$
Would you allow for figures 0-9?
Yes
Otherwise this is better for simple Latin chars:
/^[a-z]+$/i
>still, the "test" function always returned false.
I showed you how to do that with accents,
did you understand the regex?
Yes
>
Why would Arabic characters match
where accented characters do not?
You're right.
>
>Do you have any good working example about it ?
I am not into working examples, but will gve you a hint.
Arabic should work the same as accented ones:
/^[a-z\u0600-\u06ff]+$/
[http://unicode.org/charts/PDF/U0600.pdf]
Not knowing Arabic I cannot test that.
I tested. It works :-)
Thank you for your help !
albert This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: chepiok |
last post by:
I'd like to send email containing accents (french one) using PHP
command mail(). The content of these emails are store in text files.
I'de like to know :
- text file format (encoding, with ASCII code ?...) that will contains
my templates with some potential accents
- the right header that i should give to the mail commande
|
by: c w |
last post by:
Can anyone point me in the right direction?
Using Oracle 9i, Pro*C and Excel. I am trying to print french accents from
the Oracle DB
using Pro*C to extract the necessary info and sent the result to Excel but
at the moment
I cannot get the accents to show in Excel. The NLS_LANG is America.
Any help would be appreciated. Thanks.
Colin
|
by: Wim Roffal |
last post by:
When I sort texts with accents the accents end up in the end instead of near
the same text without accent.
For example, the 3 composers Händel, Haydn and Holst will appear in the
order Haydn, Holst, Händel.
Is it possible to instruct MySql to ignore the accents so that Händel comes
in first instead of last?
Thanks in advance,
|
by: Ghislain Benrais |
last post by:
Hi everybody,
I have xml documents with external entities for my accents that I
want to output properly with php function domxml_open_file. I can't get
my accents on a linux-apache server (I get "é" instead of "é"). My
browser is IE6. Do you know why ? A strange thing is that the very same
script on the same document works fine on a windows-apache server.
My xml document :
<?xml version="1.0" ?>
<!DOCTYPE survey >
|
by: bill tie |
last post by:
I'd appreciate it if you could advise.
1. How do I replace "\" (backslash) with anything?
2. Suppose I want to replace
(a) every occurrence of characters "a", "b", "c", "d" with "x",
(b) every occurrence of characters "p", "q", "r", "s" with "y".
Right now, I do it as follows:
| |
by: Chris Leffer |
last post by:
Hi.
I am having problems to use HtmlEncode with strings that use accents. My
page uses some expressions like that:
<%# Server.HtmlEncode(DataBinder.Eval(Container.DataItem, "Name").Trim)
%>
If the 'Name' has no accents all works well. But if the 'Name ' has
accents they appear encoded, like Nã.
|
by: bssjohn |
last post by:
Dear All,
I have developing a French website using PHP & Ajax. In that I tried to display some French texts from mysql database using Ajax. Form local I got the text from db with
Correct accents but in online French accents are missing. The text displays like this “de r?isation pour regroup?a majorit?es “. I declared following code in the head section of the file.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
|
by: theduffman |
last post by:
Hi, I'm trying to write code to update nightly some NHL stats. Everything works, except for names with an accent, e.g. José Théodore. This won't generate a match no matter what I try. I've edited the code to show the relevant pieces. What I use:
$data = file_get_contents('http://avalanche.nhl.com/team/app?service=page&page=Stats');
$regex = '/'.str_replace(" ", "\s", $row2).'<\/a>\n<\/td>...........
preg_match($regex, $data,...
|
by: AMP |
last post by:
Hello,
I am coming back to a project and I dont remember what the following
Regex says
I do know it removes all \r\n from the string, but I dont see how.
Can someone explain this one?
Regex re = new Regex(@"(+)",
RegexOptions.Compiled);
string op = re.Replace(FileToParse, "");
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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...
| |
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...
|
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...
|
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();...
|
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...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |