EDIT: Or in your stylevar all = "1234567890123456789012345678901234567890"; all = all.substring(0,25); As a general rule, try to keep things simple. JavaScript can work out whether the string is too long, you don't have to worry about it.
@ShaolinauthorSep 27.2008 — #Thanks. That was really simple in comparsion to what I was doing! I have another problem, at the end of some of my words I have a comma. How do I check for and delete it? Note that there will be commas in other parts of the sentence but the one I want to delete is the one that comes at the end of the word.
@Declan1991Sep 27.2008 — #I'm not sure exactly what you mean. "hello, hello, hello," should one or three commas be deleted. I'll presume it's three, and this is what you'd usevar all = "1234567890123456789012345678901234567890"; all = all.substring(0,25).replace(/(w),/g,"$1");
@DokSep 28.2008 — #Wouldn't [CODE]all = all.substring(0,25).replace(/(w),/g,"$1");[/CODE] be the same as [CODE]all = all.substring(0,25).replace(/,/g, '');[/CODE] ?
(BTW: Comma is not a special char so it shouldn't be escaped)
@Declan1991Sep 28.2008 — #Comma doesn't have to be escaped, but I prefer to escape all punctuation, it still works.
replace(/(w),/g,"$1");
replaces a comma if it's at the end of a word, while the other replaces all commas regardless of where they are. I'm not a hundred percent sure what the person wants, but looking at it again, this is probably what they want.all = all.replace(/(w),/g,"$1").substring(0,25);