A
Andreas Bergmaier
Hello,
is there a definition list for which characters match the RegExp /\s/
(and followed by all implementations)? Im currently looking for the
non-breaking-space \u00A0. I found some scripts that use [\s\uA0] in
RegExps, so I wondered whether this is really needed.
A quick (and maybee dirty) test script:
function test(x) {
var r = [];
for (var i=0; i<0x10000; i++) // 65536
if (x.exec(String.fromCharCode(i)))
r.push(i);
r = r.map(function(i){
return "\\u"+i.toString(16)+" bzw \\x"+i.toString(10) +
": '"+String.fromCharCode(i)+"'"
});
return r.join("\n");
}
Called with test(/\s/); it returned in Firefox
\u9 bzw \x9: ' '
\uA bzw \x10: '
'
\uB bzw \x11: ''
\uC bzw \x12: ''
\uD bzw \x13: '
'
\u20 bzw \x32: ' '
\uA0 bzw \x160: ' '
\u1680 bzw \x5760: ' '
\u180E bzw \x6158: 'á Ž'
\u2000 bzw \x8192: ' '
\u2001 bzw \x8193: 'â€'
\u2002 bzw \x8194: ' '
\u2003 bzw \x8195: ' '
\u2004 bzw \x8196: ' '
\u2005 bzw \x8197: ' '
\u2006 bzw \x8198: ' '
\u2007 bzw \x8199: ' '
\u2008 bzw \x8200: ' '
\u2009 bzw \x8201: ' '
\u200A bzw \x8202: ' '
\u2028 bzw \x8232: '
'
\u2029 bzw \x8233: '
'
\u202F bzw \x8239: ' '
\u205F bzw \x8287: 'âŸ'
\u3000 bzw \x12288: ' '
and in Opera it added
\u200B bzw \x8203: '​'
But the non-breaking space was in both lists. So I guess [\s\uA0] is
senseless? Are there any implementions that do something else? I'm sorry
I couldn't test IE.
Bergi
is there a definition list for which characters match the RegExp /\s/
(and followed by all implementations)? Im currently looking for the
non-breaking-space \u00A0. I found some scripts that use [\s\uA0] in
RegExps, so I wondered whether this is really needed.
A quick (and maybee dirty) test script:
function test(x) {
var r = [];
for (var i=0; i<0x10000; i++) // 65536
if (x.exec(String.fromCharCode(i)))
r.push(i);
r = r.map(function(i){
return "\\u"+i.toString(16)+" bzw \\x"+i.toString(10) +
": '"+String.fromCharCode(i)+"'"
});
return r.join("\n");
}
Called with test(/\s/); it returned in Firefox
\u9 bzw \x9: ' '
\uA bzw \x10: '
'
\uB bzw \x11: ''
\uC bzw \x12: ''
\uD bzw \x13: '
'
\u20 bzw \x32: ' '
\uA0 bzw \x160: ' '
\u1680 bzw \x5760: ' '
\u180E bzw \x6158: 'á Ž'
\u2000 bzw \x8192: ' '
\u2001 bzw \x8193: 'â€'
\u2002 bzw \x8194: ' '
\u2003 bzw \x8195: ' '
\u2004 bzw \x8196: ' '
\u2005 bzw \x8197: ' '
\u2006 bzw \x8198: ' '
\u2007 bzw \x8199: ' '
\u2008 bzw \x8200: ' '
\u2009 bzw \x8201: ' '
\u200A bzw \x8202: ' '
\u2028 bzw \x8232: '
'
\u2029 bzw \x8233: '
'
\u202F bzw \x8239: ' '
\u205F bzw \x8287: 'âŸ'
\u3000 bzw \x12288: ' '
and in Opera it added
\u200B bzw \x8203: '​'
But the non-breaking space was in both lists. So I guess [\s\uA0] is
senseless? Are there any implementions that do something else? I'm sorry
I couldn't test IE.
Bergi