18147RE: [Clip] String Split
- Aug 1, 2008Don,
You have correctly interpreted the regex. I thought the lines were already split, and the goal was just to add the space
at the end.
At this point, it would be helpful to see a snippet of source with a clear explanation of what is needed. Regex can
probably do everything in one command.
\R means any line terminator, even a combination of CRLF. I use that in the find side, and use \n or ^%NL% in the
You are right about the spaces - it would need to be \s* to capture zero or multiple spaces. I wrote it thinking there
might already be only one space.
From: firstname.lastname@example.org [mailto:email@example.com] On Behalf Of Don - HtmlFixIt.com
Sent: Friday, August 01, 2008 6:31 AM
Subject: Re: [Clip] String Split
John Shotsky wrote:
> It can also be done throughout a document with a Replace command, such as:place
> ^!Replace "(.+)\s?\R" >> "$1^%SPACE%^%NL%" ARSTW
> This will replace any existing spaces with a single space, or add a space if there is not one present. It will not
> a space in a blank line.Wow, much as I don't understand it, I love regex! What power!
Okay so .+ means one or more of any character(s) except a new line.
That is matched and put into a match string that can be referred to as
$1 because it is contained in parenthesis, so on the back side, $1
\s means white space, so a space before an \R (meaning a return
character -- I'm still in the habit of using \r\n instead I think ...)
and the ? means zero or one, so the space is optional, but if no space,
no problem and if space, it is left our of the $1 match string.
Of course the back side is reinsert everything but the trailing space,
add a space to each line and add a new line.
However, he was trimming to 70 characters, won't this make variable
length lines that may be either 71 (if no space) or 70 is space because
you trim and then reinsert a space?
I am not seeing how this eliminates existing spaces (as in multiples) if
that was what you meant by replacing existing spaces, or did you mean
one per line at the end?
Thanks for the exercise as these really help me John,
[Non-text portions of this message have been removed]
- << Previous post in topic Next post in topic >>