Re: Updating string/array items
- From: Dr J R Stockton <jrs@xxxxxxxxxxxxxxxxxx>
- Date: Wed, 17 Oct 2007 19:18:06 +0100
In comp.lang.javascript message <Xns99CBDB791482Aeejj99@xxxxxxxxxxxxxxx>
, Tue, 16 Oct 2007 19:34:28, Evertjan. <exjxw.hannivoort@xxxxxxxxxxxx>
posted:
It is impossible to provide for all minor languages.That'll upset the French.
O'Brian French?????
Well, he (Patrick) did live there.
<FAQENTRY>AISB, the FAQ is weak on RegExps. This topic would supply a
suitable example, perhaps presenting the simplest and the finest
solutions. I like the approach of your
String.prototype.toProper = function(){
return this.replace( /(\b\w)(\w*)/g ,
function(x,a,b){return a.toUpperCase()+b.toLowerCase();});
};
with a rearrangement of whitespace and a note about languages with
alphabets other than 26 A-Z.
For the OP : the simplest way may be to step character-by-character with
..charAt through the original string, noting whether the present
character is a letter and retaining one value of that in the next step,
and doing .toLowerCase or .toUpperCase accordingly before adding to what
has been processed so far.
But note that the test "Ban Ki-moon from RoK is S-G of the UN" could be
hard to pass by any method.
It's a good idea to read the newsgroup c.l.j and its FAQ. See below.
--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 IE 6
news:comp.lang.javascript FAQ <URL:http://www.jibbering.com/faq/index.html>.
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
.
- References:
- Updating string/array items
- From: Xcriber51
- Re: Updating string/array items
- From: matatunos
- Re: Updating string/array items
- From: Henry
- Re: Updating string/array items
- From: getsanjay . sharma
- Re: Updating string/array items
- From: Henry
- Re: Updating string/array items
- From: pr
- Re: Updating string/array items
- From: Evertjan.
- Re: Updating string/array items
- From: pr
- Re: Updating string/array items
- From: Evertjan.
- Re: Updating string/array items
- From: pr
- Re: Updating string/array items
- From: Evertjan.
- Updating string/array items
- Prev by Date: Re: Javascript building blocks
- Next by Date: Table scroll
- Previous by thread: Re: [OT]Re: Updating string/array items
- Next by thread: Re: Updating string/array items
- Index(es):
Relevant Pages
|