$string=~s/(\.+)([^\s])/$1 $2/;
rephrasing your question as 'replace one or more periods with the same number of periods and a space if the next character is not whitespace'
(,
Sun 20 Apr 2008, 6:19,
archived)
rephrasing your question as 'replace one or more periods with the same number of periods and a space if the next character is not whitespace'
that looks promising, thanks! And your rephrasing is much clearer, that's indeed exactly what I need.
But... the ~s at the beginning is unfamiliar. What does it do? It's possible it's used in JavaScript, but it may not be, not all of Perl's reg ex syntax is included.
Edit: Ok, I've tried this without the leading ~s and I'm getting an unhelpful javascript error... I think the problem is the repeated / near the end of the reg ex here... javascript uses / as the reg ex delimiter.
(,
Sun 20 Apr 2008, 6:24,
archived)
But... the ~s at the beginning is unfamiliar. What does it do? It's possible it's used in JavaScript, but it may not be, not all of Perl's reg ex syntax is included.
Edit: Ok, I've tried this without the leading ~s and I'm getting an unhelpful javascript error... I think the problem is the repeated / near the end of the reg ex here... javascript uses / as the reg ex delimiter.
Good luck and have fun.
(,
Sun 20 Apr 2008, 6:28,
archived)
~s/ is just the replace operator. For example ~s/old/new/ replaces 'old' with 'new'.
Perl has these auto variables $1, $2 etc that correspond to brackets () you put in the reg exp. I guess what's missing in your code above is the $2. that's what's removing your Y.
(,
Sun 20 Apr 2008, 6:30,
archived)
Perl has these auto variables $1, $2 etc that correspond to brackets () you put in the reg exp. I guess what's missing in your code above is the $2. that's what's removing your Y.
I really appreciate your help.
I don't know if I can adapt the code sample you've given me, but the rephrasing is really helpful, I'm much clearer now about what I need to achieve.
Thanks!
(,
Sun 20 Apr 2008, 6:35,
archived)
I don't know if I can adapt the code sample you've given me, but the rephrasing is really helpful, I'm much clearer now about what I need to achieve.
Thanks!
newString = oldString.replace(/\.(?!\.|\s)/g, ". ");
seems to work. English goes: Replace a "." which is not followed by a "." or a " "
but you know. i'm no expert.
(,
Sun 20 Apr 2008, 6:41,
archived)
seems to work. English goes: Replace a "." which is not followed by a "." or a " "
but you know. i'm no expert.
which checks following characters without operating on them, very clever, why didnt I think of that.
COUGH
(,
Sun 20 Apr 2008, 6:43,
archived)
COUGH
but I'm sure the question will resolve it's self in time.
just make sure you go before the journey
(,
Sun 20 Apr 2008, 6:40,
archived)
just make sure you go before the journey
as you say, the question did resolve itself many times before. IN MY PANTS.
(,
Sun 20 Apr 2008, 6:49,
archived)
newString = oldString.replace(/\.(?!\.|\s)/g, ". ");
seems to work. English goes: Replace a "." which is not followed by a "." or a " "
(,
Sun 20 Apr 2008, 6:38,
archived)
seems to work. English goes: Replace a "." which is not followed by a "." or a " "
something i don't know about. looks like problem solved then
(,
Sun 20 Apr 2008, 6:46,
archived)