b3ta.com board
You are not logged in. Login or Signup
Home » Messageboard » XXX » Message 8302314 (Thread)

# Ok
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)
# That's a bit odd
*thinking*
(, Sun 20 Apr 2008, 6:23, archived)
# Just because it's been so long since i doned anything like this i'm interested to see if I'm right, here it is again
newString = oldString.replace(/\.(?!\.|\s)/g, ". ");
(, Sun 20 Apr 2008, 6:46, archived)
# Oooh you beauty :)
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)
# Here's the link i ultimately ended up at:
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)