Forum Moderators: open
All apologies, I just couldn't help myself. Please consider this a gratuitous bump.
[edited by: Rambo_Tribble at 4:23 pm (utc) on Feb. 16, 2006]
Back in Blighty, when studying or coding, it's tempting to take the attitude: "I'll think about that later", or "Well, it's their own silly fault for being so foreign". In Stockholm, of course, at work or in the classroom, these characters just won't go away.
Putting a customer input form on the Web is like that, but worse. I still can't think of a generalised solution.
Try:
alert(/\w/.test("ä")) Javascript (Rhino) thinks ä is a word character.
JScript disagrees.
I was thinking of proposing:
char.toLowerCase()!= char.toUpperCase();
but that would lose characters that have no upper¦lower case defined, like ß
The King is in the altogether, the altogether,..
Anyway, with server-side languages having more powerful regular expression tools, isn't this a job for AJAX-man? (cue the music and pan to the phone booth)
<script type="text/javascript">
function strtest(string) {
alert('Before\n' + string);
string = eval("string.replace(/([^a-z])/gi, function(chr) { charCode = chr.charCodeAt(0); if(charCode < 192 ¦¦ charCode > 255 ¦¦ charCode == 215 ¦¦ charCode == 247) { return ''; } else return chr; })");
alert('After\n' + string);
}
strtest("!te@st#in%g");
strtest("@å#ä$ö*");
</script>
That should let all letters in ISO-8859-1 pass :)
g - global
This would be needed (for instance) if you were doing a replace, else it would stop after first replacement:
"ABBA".replace(/B/,"X") // -> AXBA
"ABBA".replace(/B/g,"X") // -> AXXA
i - ignore case
"ABBA".replace(/b/g,"X") // -> ABBA
"ABBA".replace(/b/gi,"X") // -> AXXA
>> Q1. /[^A-Z a-z \(\)-]+/
Nothing wrong with it. It works. You could save a few chars..
- The + is unnecessary here
- It has two spaces
- Use i
/[^A-Z \(\)-]+/i
>> Q2. /[^A-Za-z]+/
Fine. Same things apply..
/[^A-Z]/i
R. Tribble: And wouldn't the nominative be appropriate for the titular?
Since you were addressing Regem Maximum, I would say that that vocative is our man.
Doc, I had an idea concerning your latest
..but I'd better do some work first.
"Since you were addressing Regem Maximum . . ."
I see your point. But, on a technical note, since this is the electronic medium, shouldn't the e-vocative be used? Granted, I tend more toward the provocative, myself.
DrDoc, I appreciate what you're saying and I have heard it before. I'm just not sure I entirely buy into it for every case. Efficiency has to count for something.
A thought occurs, though I don't have time to investigate it, at the moment; I wonder if URL-encoding of the string could offer any relief for testing purposes?
eval). I really don't know much about character encoding etc, so I'm accepting his figures (and wisdom). I think there is a way to perform the same logic as his function, but with a straight
replace(reg.""). This would be done using ranges of unicode escapes [\uMMMM-\uNNNN]. I started on it, then I realised that I have some ASP soup to unravel, which will take a while, since I added the noodles myself.
But, on a technical note, since this is the electronic medium, shouldn't the e-vocative be used?
I decline to take this matter any further.
[webmasterworld.com...]
Accessibility > Cognitive
To refrain from using the tools our language provides is to make the richness of that language unaccessible. Should all education and learning stop at the fifth grade? Vehemence is about passion; if we emasculate our verbiage, what passion can it hold? How usable is a language bereft of the many colors and textures of meaning contained in a broader and deeper lexicon?