View Single Post
  #6 (permalink)  
Old 08-09-2007, 11:32 AM
dak888 dak888 is offline
WebProWorld Member
 
Join Date: Nov 2006
Posts: 79
dak888 RepRank 0
Default Re: Javascript and those naughty characters...

Ok, you've given me a bit to chew on here...


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

Yes, I want to allow the space. I basically just want to be left with text with no formatting or special characters. Although I should say I would like to keep the special characters like "", ; , etc... as that would make the text more understandable to the user. But I don't know if those are actually breaking the code.

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

I suppose I would want to include it since it may represent a space between two words.

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

I would want it to be "natural" casing. If the letter in the text file is upper case, then keep it that way, etc...

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

I'll have to read about that, reg expressions are new to me.

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

No, just remove them.

6. Do you need trim to single-spacing?

Yes.

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

I don't know. I'll try it and see what it does. Regular expressions are new to me.

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

If I'm seeing html where? The text file that is being processed may have html in it but I don't want it in the search results.

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.

I'll have to read about this. You pretty much spoke Chinese to me there. LOL.

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

How should I be declaring it?

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]

You lost me here...

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

That can be easily corrected.

Thanks for all the questions? Hopefully you or someone can pin down my problem.

DaK
Reply With Quote