View Single Post
  #5 (permalink)  
Old 08-08-2007, 09:09 PM
lanthus lanthus is offline
WebProWorld New Member
 
Join Date: Apr 2005
Posts: 18
lanthus RepRank 0
Default Re: Javascript and those naughty characters...

More questions than questions there--

1. You want to allow the {space}?-- You said only "A-Z and 0-9"

2. Do you want to not-include nbsp?-- which get generated automatically in some html processing.

3. Do you later .toUpperCase() it?-- in which case NBSP in-caps fails...?

4. Would /[^\w ]+/ be simpler?-- except of course you may not want the "_" of \w

5. Would you want to convert unusable characters to space?

6. Do you need trim to single-spacing?

7. Why not simply, write textpreview.replace(/^(.{50}).+/,'$1...')

8. If you're seeing html, look for .innerHTML, htmlText in lieu of .innerText, text, data,...

9. NB. document.selection.createRange().text has empty-cells-of-zero-length for BR's ... like weapons of mass destruction they can be elusive in textonly.

10. [thinking... script type="text/JavaScript" might be choosing an old-version of javascript...]

11. [thinking... if you use RegExp.$1 you need make sure it matched something, else RegExp.$1 is old data from the last match... and would be anything]

12. " ..." should be "..." without the space because it may land in the middl... (And … is one-character for that.)
__

PS. Here's a ms-bug: Find-in-page "a  b ™c" (when rendered) fails till you remove either the nbsp or the trademark ... I reported this to MS today....

Ray.
__________________
Mr. Raymond Kenneth Petry
Lanthus Corporation

Last edited by lanthus; 08-08-2007 at 10:06 PM.
Reply With Quote