Loading ...
Sorry, an error occurred while loading the content.

18144Re: [Clip] String Split

Expand Messages
  • Don - HtmlFixIt.com
    Aug 1, 2008
      John Shotsky wrote:
      > It can also be done throughout a document with a Replace command, such as:
      > ^!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 place
      > a space in a blank line.
      > John

      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
      reinserts that.

      \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,

    • Show all 11 messages in this topic