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

Re: [Clip] Regular Expressions and NewLine

Expand Messages
  • Eb Guenther
    Hi Larry, and all, ... Thanks, I tried it with the same results. It DID confirm that my search afforts were going in the right directions. Subsequently I found
    Message 1 of 3 , Aug 5, 2000
    • 0 Attachment
      Hi Larry, and all,

      > >Is there some special syntax to use to find, for
      > >example a two-line pattern?
      >
      >You can try \a. There is a problem though in that it tends to find the
      >last occurrence of whatever I end it with.

      Thanks, I tried it with the same results. It DID confirm
      that my search afforts were going in the right directions.
      Subsequently I found my syntax error.

      However, I immediately came up with a new problem:

      I'm trying to scan a library to replace each clip header
      with the same header followed by a special comment, such
      as a copyright.


      I have:
      H="every clip header not a comment"
      ;old line 1 of each clip

      I want:
      H="every clip header not a comment"
      ;my comment
      ;old line 1 of each clip

      I tried (logically):
      ^!Replace ^{H="[^;].*"} \1^%NL%;my comment RIS
      ^!IfError Exit

      but got:(
      H="\1"
      ;my comment
      ;old line 1 of each clip

      Not only did the placeholder not work,
      neither did the "\" escape the "1".

      What went wrong? The following Mickey Mouse solution
      works, using twice as many lines. This proves that my
      regexp is ok:
      ^!Find ^H="[^;].*" RIS
      ^!IfError Exit
      ^!Set %header%=^$GetSelection$
      ^!Replace ^%header% ^%header%^%NL%;my comment IS


      So what is wrong with the "\1" and the expression it
      is supposed to hold '{H="[^;].*"}' ?

      I quote from help "curly braces {} forms a tagged match word"
      and "when "\" is followed by a single digit in the range of
      1 through 9 ... the tagged match word found by the Find
      expression is used in the resulting replacement text."

      In other (UnIX) words, {exprA},{exprB},..,{exprI} is loaded
      into the place holders \1,\2,..,\9. Just like the Unix
      (A),(B),..,(I) --> $1,$2,..,$9, which works.


      Cheers.


      Eb
    • Jody
      Hi Eb, ... Those are not working correctly from a Clip if I am reading it correctly. It was reported to Eric awhile back. You will probably find they work
      Message 2 of 3 , Aug 5, 2000
      • 0 Attachment
        Hi Eb,

        > I tried (logically):
        > ^!Replace ^{H="[^;].*"} \1^%NL%;my comment RIS
        > ^!IfError Exit

        Those are not working correctly from a Clip if I am reading it
        correctly. It was reported to Eric awhile back. You will
        probably find they work from the Replace dialog.


        This is from Help which you have probably seen:

        Examples:
        The following examples use the NoteTab Replace dialog box
        (press Ctrl+R to open it). Make sure you tick the "regex box"
        before trying them.

        Changes all H2 tags to H3:
        Find: <H2>{.*}</H2>
        Replace with: <H3>\1</H3>

        Strips trailing blanks from each line:
        Find: ^{.+[^\s]}\s*
        Replace with: \1

        Places each encountered word on a single line (Replace All can
        take quite long on big files!):
        Find: \w*{['$#A-Z0-9]+}\w*
        Replace with: \1\n

        Happy Test'n,
        Jody Adair

        Subscribe, UnSubscribe, Options
        mailto:ntb-beta-Subscribe@...
        mailto:ntb-beta-UnSubscribe@...
        http://www.egroups.com/group/ntb-beta
      Your message has been successfully submitted and would be delivered to recipients shortly.