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

Re: [Clip] Regular Expressions and NewLine

Expand Messages
  • Larry Thomas
    Hi Eb, ... You can try a. There is a problem though in that it tends to find the last occurrence of whatever I end it with. If I search of ...123 at the end
    Message 1 of 3 , Aug 3, 2000
      Hi Eb,

      At 01:20 PM 08/03/2000 -0400, you wrote:
      >Hi Clippers,
      >
      >RegExp again.
      >
      >Can "^!Find ..." loacate more than one line of text?
      >Looking at the special definitions, \n and \b
      >would imply yes, but in practice I have been
      >unable to use a clip to find more than one line
      >at a time.
      >
      >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. If I search of ...123 at the
      end of the expression and there are five of them in the searched text, Find
      will select all of the text from the start of the found text to the last
      occurrence of ...123. It will not stop at the first occurrence of ...123
      as I would like. I know that Gawk and Perl have this capability but the
      NoteTab Regexp function does not seem to.

      Regards,

      Larry
      larryt@...
    • 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 2 of 3 , Aug 5, 2000
        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 3 of 3 , Aug 5, 2000
          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.