RE: [Clip] String Split
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]
- --- In firstname.lastname@example.org, Axel Berger <Axel-Berger@...> wrote:
>I'm not sure StrSplit is doing.
> With the command
> ^!InsertText ^$StrSplit("^$GetSelection$";70;FALSE)$
> I had expected every line to end with a space before the return.
> Isn't that what the FALSE stands for? Not so, no space. What's
I have View Nonprinting characters enabled.
If I have a document with:
abc followed by 70 spaces followed by abc followed by three spaces
And I highlight that and run the above clip, it keeps all the spaces
and the two resulting lines both start with abc.
If I change the FALSE to TRUE, I get exactly the same result.
If I do the same thing in NTP version 4.95, with TRUE the trailing
spaces get removed and both lines have just abc on them.
So it would seem that the function's behavior changed at some point. I
am currently running NTP 5.7b.
- "Don - HtmlFixIt.com" wrote:
> Provides#stronger#That's what I expected to happen. Doesn't do so here. As it works
for you, the mistake must be somewhere one my side.
- Axel Berger wrote:
> "Don - HtmlFixIt.com" wrote:I am apparently in 5.5. I have 5.7, but need to get it to start when I
> That's what I expected to happen. Doesn't do so here. As it works
> for you, the mistake must be somewhere one my side.
click on notetab. Perhaps the version number does have something to do
I tried Sheri's example and got very odd results. If you have abc[bunch
of spaces]abc[spaces] it doesn't trim the spaces up to the width with
true, but does trim them after the width. With False, it doesn't trim
any spaces, so you are left with lines with spaces going out way past
the specified width!
- "Don - HtmlFixIt.com" wrote:
> If I use FALSE at the end, all lines are hard wrapped/split atNot quite. I have found my mistake here. I have got into the habit
> 70 or less and there is a trailing space on the line ... if it
> is wrapped. FALSE stops it from removing the trailing space
> that caused the split, in other words.
of writing a capital "FALSE" which usually works, but not in
^$StrSplit. This function requires "False" exactly as in the help
file, so there's noone to blame but me.