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

RE: [NTB] Regular Expression Help

Expand Messages
  • Hugo Paulissen (Unimaas)
    Hi Veli-Pekka, You had some trailing white spaces, these are tackled by s* in the regexp. You may need other options (RIS=Regular
    Message 1 of 7 , Dec 5, 2002
    • 0 Attachment
      Hi Veli-Pekka,

      You had some trailing white spaces, these are tackled by \s* in the regexp.
      You may need other options (RIS=Regular Expr./Case-Insensitive/Silent), but
      read the help-pages for that.

      ^!Replace "{<p>}\s*\n{<h\d>.*<\/h\d>}" >> "\2\n\1" RIS

      Does the job for the first one.

      \d is a digit
      {}-matches can be retrieved in the replace-string by \1 through \9...

      The match <p> is returned in the replacement by \1, everything between <h1>
      and </h1> by \2.
      \n is inserted for a new line
      Note that .* finds zero or more characters ON ONE LINE ONLY.

      The second one can be done with...

      ^!Replace "<p>\s*\n{<h\d>.+<\/h\d>}\s*\n<\/p>\s*\n+" >> "\1\n" RIS


      Regards,


      Hugo

      >
      > Anyway, here's what I want to do explained in pseudo language:
      >
      > 1)
      >
      > Find:
      >
      > <p>
      > <h#> ... </h#>
      >
      > Replace with:
      > <h#> ... </h#>
      > <p>
      >
      > Example:
      >
      > <p>
      > <h3> Heading number three </h3>
      > Some text in here.
      >
      > would be changed to:
      > <h3> heading number three </h3>
      > <p>
      > Some text in here.
      >
      > 2)
      > find:
      > <p>
      > <h#> ... </h#>
      > </p>
      > ... // possible new lines
      > <p>
      >
      > Replace with:
      > <h#> ... </h#>
      > <p>
      >
      > Example:
      > <p>
      > <h3> another heading </h3>
      > </p>
      >
      > <p>
      >
      > Would be replaced with:
      > <h3> another heading </h3>
      > <p>
      >
      >
      >
    • Sheri
      Hi Veli, It appears you have some spaces at line ends, so you must trim blanks before trying the following. It is useful to display non-printing characters
      Message 2 of 7 , Dec 5, 2002
      • 0 Attachment
        Hi Veli,

        It appears you have some spaces at line ends, so you must trim blanks
        before trying the following. It is useful to display non-printing
        characters when working with regexp. It is possible to write
        expressions that allow for spaces at line ends, but why complicate
        things unless you need the spaces?

        1)Find: {<p>\n}{<h[0-9]>.*</h[0-9]>\n}
        Replace: \2\1
        RegExp: X

        2)Find: {<p>\n}{<h[0-9]>.*</h[0-9]>\n}</p>\n+<p>\n
        Replace: \2\1
        RegExp: X

        The "find" parts in curly braces become numbered fields referenced in
        the replace clauses. The parts in square brackets show the range of
        acceptable values for that position. The \n+ means one or more new
        lines. The .* Means any number of characters except new lines.

        Hope they works ok. If this is something you might want to use again
        sometime you could save the replace commands in clips. Come over to
        the clips list if you'd like help doing that.

        Regards,
        Sheri
      • bizshop1
        I m trying to use the regular expression function and have spent the last * hours trying different combos, searching the web, etc. I have lines similar to:
        Message 3 of 7 , Sep 1, 2003
        • 0 Attachment
          I'm trying to use the regular expression function and have spent the
          last * hours trying different combos, searching the web, etc.

          I have lines similar to:

          include("masthead.php");
          blueFont("Arial","How many additional copies of \"$title\" do you
          want?");

          I'm shifting to CSS and want to change second line to

          include("masthead.php");
          echo "How many additional copies of \"$title\" do you want?";

          The enclosed $ or \" are causing me fits....
        • John Zeman
          If you have the first section of text selected with the RegExp option previously enabled in the Replace dialog box, the Replace dialog will escape certain
          Message 4 of 7 , Sep 1, 2003
          • 0 Attachment
            If you have the first section of text selected with the RegExp option
            previously enabled in the Replace dialog box, the Replace dialog will
            escape certain characters effectively changing \"$title\" into
            \\"\$title\\" is that what you are referring to?

            If so, try unchecking the RegExp option first, then enabling it after
            you have the text entered.

            John


            --- In notetab@yahoogroups.com, "bizshop1" <steve@b...> wrote:
            > I'm trying to use the regular expression function and have spent
            the
            > last * hours trying different combos, searching the web, etc.
            >
            > I have lines similar to:
            >
            > include("masthead.php");
            > blueFont("Arial","How many additional copies of \"$title\" do you
            > want?");
            >
            > I'm shifting to CSS and want to change second line to
            >
            > include("masthead.php");
            > echo "How many additional copies of \"$title\" do you want?";
            >
            > The enclosed $ or \" are causing me fits....
          • Alec Burgess
            Bishop Greg s advice about allowing Notetab to help by auto-converting to handle some of the characters that need to be escaped should help. For your specific
            Message 5 of 7 , Sep 1, 2003
            • 0 Attachment
              Bishop

              Greg's advice about allowing Notetab to help by auto-converting to handle
              some of the characters that need to be escaped should help.

              For your specific example (w/o the "=="):

              RegExp: ==blueFont\("Arial",{".*}\);\s*$==
              Replace: ==echo "\1==

              Note: the \s* on the end is in case you have trailing spaces

              It may be possible to do it more generally than this, but you might be
              getting trapped by the " at the end of the font name and the " in \"title\".
              Notetab's current rage is greedy to if you have any sort of a wildcard
              before a " it will run all the way to the last one.

              If there are several fonts that are all to get reduced to an "echo",
              something like this might work:
              (("Arial")|("Helvetica")|("anyotherFONT")) in place of the specific "Arial"
              though I confess that I wasn't able to get this one to work - probably some
              silly typo I'm missing.

              the \s* at the end is in case there are trailing spaces.

              If you do need the more general case, post back with 5 or 6 examples of what
              you're starting with, and what you need to end up with.

              Regards ... Alec
              --

              ---- Original Message ----
              From: "bizshop1" <steve@...>
              To: <notetab@yahoogroups.com>
              Sent: Monday, September 01, 2003 07:10
              Subject: [mla: [NTB] Regular Expression Help

              > I'm trying to use the regular expression function and have spent the
              > last * hours trying different combos, searching the web, etc.
              >
              > I have lines similar to:
              >
              > include("masthead.php");
              > blueFont("Arial","How many additional copies of \"$title\" do you
              > want?");
              >
              > I'm shifting to CSS and want to change second line to
              >
              > include("masthead.php");
              > echo "How many additional copies of \"$title\" do you want?";
              >
              > The enclosed $ or \" are causing me fits....
              >
              >
              >
              >
              >
              >
              > ------------------------ Yahoo! Groups Sponsor
              >
              > To unsubscribe click on address below and send the message empty:
              > mailto:notetab-unsubscribe@yahoogroups.com
              > http://groups.yahoo.com/list/notetab
              >
              > Your use of Yahoo! Groups is subject to
              > http://docs.yahoo.com/info/terms/
            • james.homme@highmark.com
              Hi, Why won t an exact replace work? Thanks. Jim bizshop1 cc: Subject:
              Message 6 of 7 , Sep 2, 2003
              • 0 Attachment
                Hi,
                Why won't an exact replace work?

                Thanks.

                Jim




                "bizshop1"
                <steve@... To: notetab@yahoogroups.com
                m> cc:
                Subject: [NTB] Regular Expression Help
                09/01/2003 07:10
                AM
                Please respond to
                notetab






                I'm trying to use the regular expression function and have spent the
                last * hours trying different combos, searching the web, etc.

                I have lines similar to:

                include("masthead.php");
                blueFont("Arial","How many additional copies of \"$title\" do you
                want?");

                I'm shifting to CSS and want to change second line to

                include("masthead.php");
                echo "How many additional copies of \"$title\" do you want?";

                The enclosed $ or \" are causing me fits....






                Yahoo! Groups Sponsor








                To unsubscribe click on address below and send the message empty:
                mailto:notetab-unsubscribe@yahoogroups.com
                http://groups.yahoo.com/list/notetab

                Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
              Your message has been successfully submitted and would be delivered to recipients shortly.