
find .
read next char
if not space
replace with space + char
or
find .
read next char
if not space
insert space in string at relevant point (the position of which you should be able to drag from your loopish searchy algodoodah)
( ,
Sun 20 Apr 2008, 5:57,
archived)
read next char
if not space
replace with space + char
or
find .
read next char
if not space
insert space in string at relevant point (the position of which you should be able to drag from your loopish searchy algodoodah)

And the most efficient way to do that is with JavaScript's replace function and a smart regular expression.
I got very close, I guess I'll just have to persevere until I get the last part right.
( ,
Sun 20 Apr 2008, 6:00,
archived)
I got very close, I guess I'll just have to persevere until I get the last part right.

Damn my being out of practice. Any chance you could post what you have, I might be able to adapt it a little
( ,
Sun 20 Apr 2008, 6:02,
archived)

newString = oldString.replace(/\.+[^\.\s]/g, ". ");
Here's the result of this:
"Yes no.Yes no. Yes no. Yes no..."
becomes
"Yes no. es no. Yes no. Yes no..."
It's doing everything I need (which is to say, it's not adding spaces where it shouldn't), with the exception that it replaces the Y after the period.
( ,
Sun 20 Apr 2008, 6:11,
archived)
Here's the result of this:
"Yes no.Yes no. Yes no. Yes no..."
becomes
"Yes no. es no. Yes no. Yes no..."
It's doing everything I need (which is to say, it's not adding spaces where it shouldn't), with the exception that it replaces the Y after the period.

newString = oldString.replace(/\.(?!\.|\s)/g, ". ");
( ,
Sun 20 Apr 2008, 6:46,
archived)

Fucking yeah, that's perfect.
I'll study what you've done and see if I can figure out how it works. I may be able to make some of the earlier string operations more efficient now too.
Thanks man, I owe you one.
Edit: lookahead! Who knew?
( ,
Sun 20 Apr 2008, 6:56,
archived)
I'll study what you've done and see if I can figure out how it works. I may be able to make some of the earlier string operations more efficient now too.
Thanks man, I owe you one.
Edit: lookahead! Who knew?

www.regular-expressions.info/lookaround.html#lookahead
Keep in mind that javascript doesnt support Lookbehind though, only Lookahead.
( ,
Sun 20 Apr 2008, 6:59,
archived)
Keep in mind that javascript doesnt support Lookbehind though, only Lookahead.

Up early. Is your sleeping not as well as it should be?
( ,
Sun 20 Apr 2008, 6:20,
archived)