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

Help with RegExp

Expand Messages
  • Lee Underwood
    I am trying to get a handle on RegExp but to no avail. I have searched my archives but didn t find what I needed. I have also read the text in the help files
    Message 1 of 12 , Jan 3, 2007
      I am trying to get a handle on RegExp but to no avail. I have
      searched my archives but didn't find what I needed. I have also read
      the text in the help files plus a few online sites. I just can't seem
      to "wrap my brain around it".

      I have several lines that I need to replace which are in the midst of
      a larger text section. The text at the beginning and end of each
      portion is the same. I just don't know how to find it and replace it
      in the midst of the section. For instance, I need to find this in a
      large text portion:

      <strong>Details:</strong> 6.08 KB * Uploaded

      The part "6.08 KB" will change in each line. I need to place it with
      something like:

      <strong>Date Uploaded:</strong>

      What I need, I guess, is to understand how to find sections which
      begin and end with specific words (while the portion in the middle
      changes) and then replace it with other text.

      I would appreciate some help.

      Lee
    • buralex@gmail.com
      Lee ... ^!replace * Details: *.* *(.*) * Date *$1:* * rwasi the above is for Notetab 5 and relies on the existence of the
      Message 2 of 12 , Jan 3, 2007
        Lee

        > I have several lines that I need to replace which are in the midst of
        > a larger text section. The text at the beginning and end of each
        > portion is the same. I just don't know how to find it and replace it
        > in the midst of the section. For instance, I need to find this in a
        > large text portion:
        >
        > *<strong>Details:</strong> 6.08 KB * Uploaded*
        >
        > The part "6.08 KB" will change in each line. I need to place it with
        > something like:
        >
        > *<strong>Date Uploaded:</strong>*
        >
        > What I need, I guess, is to understand how to find sections which
        > begin and end with specific words (while the portion in the middle
        > changes) and then replace it with other text.
        ^!replace "*<strong>Details:</strong>*.*\*(.*)" >> "*<strong>Date
        *$1:*</strong>*" rwasi

        the above is for Notetab 5 and relies on the existence of the * (escaped
        with a backslash in the above) and keeps everything after the * to
        end-of-line.
        (not tested)

        Regards ... Alec -- buralex-gmail
        --



        [Non-text portions of this message have been removed]
      • Sheri
        I still recommend going through these slides, very helpful for getting a handle on regular expressions (approx 16 mb):
        Message 3 of 12 , Jan 3, 2007
          I still recommend going through these slides, very helpful for getting
          a handle on regular expressions (approx 16 mb):

          <http://www.gravitonic.com/downloads/talks/phptek-2006/regex-clinic_phptek2006.pdf>

          Here's a tinyurl for it in case Yahoo breaks the link:

          http://tinyurl.com/yn6ejl

          Hope it helps,
          Sheri
        • Lee Underwood
          Thanks but it creates a Regex error: nothing to repeat . Then gives a clip error. It doesn t do anything. Lee On 1/3/2007 10:11 PM, buralex@gmail.com wrote:
          Message 4 of 12 , Jan 4, 2007
            Thanks but it creates a "Regex error: nothing to repeat". Then gives
            a clip error. It doesn't do anything.

            Lee


            On 1/3/2007 10:11 PM, buralex@... wrote:
            ........................................................
            >^!replace "*<strong>Details:</strong>*.*\*(.*)" >> "*<strong>Date
            >*$1:*</strong>*" rwasi
            >
            >the above is for Notetab 5 and relies on the existence of the * (escaped
            >with a backslash in the above) and keeps everything after the * to
            >end-of-line.
            >(not tested)
            >
            >Regards ... Alec -- buralex-gmail
            >--
            ........................................................
          • Lee Underwood
            Sheri, Thanks. I appreciate it. It looks like a good resource. I m not giving up learning this. I want to learn it inside and out. I am just trying right now
            Message 5 of 12 , Jan 4, 2007
              Sheri,

              Thanks. I appreciate it. It looks like a good resource.

              I'm not giving up learning this. I want to learn it inside and out. I
              am just trying right now to find a solution for an immediate problem.

              Lee


              On 1/3/2007 11:39 PM, Sheri wrote:
              ........................................................

              >I still recommend going through these slides, very helpful for
              >getting a handle on regular expressions (approx 16 mb):
              >
              ><http://www.gravitonic.com/downloads/talks/phptek-2006/regex-clinic_phptek2006.pdf>
              >
              >Here's a tinyurl for it in case Yahoo breaks the link:
              >
              >http://tinyurl.com/yn6ejl
              >
              >Hope it helps,
              >Sheri
              ........................................................
            • buralex@gmail.com
              Lee: This time I tested by putting the find clause and the replace clause in the REPLACE dialog, copied your original email to a new file in Notetab. Clicking
              Message 6 of 12 , Jan 4, 2007
                Lee: This time I tested by putting the find clause and the replace
                clause in the REPLACE dialog, copied your original email to a new file
                in Notetab.
                Clicking Find and then Replace (also tried again with immediately
                clicking Replace All)

                worked both times

                also made a one-line clip out of it - worked

                Did the line I sent originally get wrapped into two lines by Yahoo? Its
                supposed to be one line.

                When I get inexplicable errors like this (happens frequently :-[ ) I
                usually try to break it down by testing in the Replace dialog, first
                putting in a sub-set of what I'm trying to do and then adding one clause
                at a time until I figure out what the "stupid" mistake is that I'm
                overlooking!

                If/when you figure it out please post back ....

                I just noticed that the replace clause as you show it in your quote it
                is totally mangled! the stuff after the >> and inside quotes is supposed
                to be exactly:
                =====>"<strong>Date $1:</strong>"<========
                In your quote of what I sent I see:
                =====>"*<strong>Date
                >*$1:*</strong>*"<========

                broken over two lines and with asterisks(stars) where they have no
                business being!


                > Thanks but it creates a "Regex error: nothing to repeat". Then gives
                > a clip error. It doesn't do anything.
                >
                > Lee
                >
                >
                > On 1/3/2007 10:11 PM, buralex@... wrote:
                > ........................................................
                >
                >> >^!replace "*<strong>Details:</strong>*.*\*(.*)" >> "*<strong>Date
                >> >*$1:*</strong>*" rwasi
                >> >
                >> >the above is for Notetab 5 and relies on the existence of the * (escaped
                >> >with a backslash in the above) and keeps everything after the * to
                >> >end-of-line.
                >> >(not tested)

                Regards ... Alec -- buralex-gmail
                --



                [Non-text portions of this message have been removed]
              • Sheri
                Hi Alec, When NoteTab gives a regex error, it is only ever referring to the search side of a replace command. You have some unescaped asterisks there,
                Message 7 of 12 , Jan 4, 2007
                  Hi Alec,

                  When NoteTab gives a regex error, it is only ever referring to the
                  search side of a replace command.

                  You have some unescaped asterisks there, especially the first
                  character. I haven't tested it, but it looks like a problem to me:

                  > "*<strong>Details:</strong>*.*\*(.*)"

                  Regards,
                  Sheri
                • Alec Burgess
                  Sheri,Lee: It looks like Thunderbird was munging what I sent (I think recognizing the strong tag in angle brackets and trying to help by putting the
                  Message 8 of 12 , Jan 4, 2007
                    Sheri,Lee: It looks like Thunderbird was munging what I sent (I think
                    recognizing the strong tag in angle brackets and trying to "help" by
                    putting the asterisks around them (the normal way to signal emphasis
                    when sending text email) (underlines similarly are used to mark
                    underlines and slashes to mark italics)

                    In any case, I'm sending this from the yahoo-groups web interface in
                    Firefox 2. Sorry for all the confusion Lee. Here's what I intended to
                    send originally (hope it comes through OK):

                    ======= (one line)
                    ^!replace "<strong>Details:</strong>.*\*(.*)" >> "<strong>Date
                    $1:</strong>" rwasi
                    ======= (end one line)
                    There are only three asterisks in the above, a dot-star, a back-slash
                    star and another dot_star in parentheses!

                    --- In ntb-clips@yahoogroups.com, "Sheri" <silvermoonwoman@...> wrote:
                    >
                    > Hi Alec,
                    >
                    > When NoteTab gives a regex error, it is only ever referring to the
                    > search side of a replace command.
                    >
                    > You have some unescaped asterisks there, especially the first
                    > character. I haven't tested it, but it looks like a problem to me:
                    >
                    > > "*<strong>Details:</strong>*.*\*(.*)"
                    >
                    > Regards,
                    > Sheri
                    >
                  • junja
                    Sending code to people who use Thunderbird for their email can be tricky, in particular over characters. Tb users should check the syntax of any code they
                    Message 9 of 12 , Jan 7, 2007
                      Sending code to people who use Thunderbird for their email
                      can be tricky, in particular over '>' characters. Tb users
                      should check the syntax of any code they copy and paste
                      which contains '>' characters against the original email.
                      junja


                      Alec Burgess wrote:
                      > Sheri,Lee: It looks like Thunderbird was munging what I sent (I think
                      > recognizing the strong tag in angle brackets and trying to "help" by
                      > putting the asterisks around them (the normal way to signal emphasis
                      > when sending text email) (underlines similarly are used to mark
                      > underlines and slashes to mark italics)
                      >
                      > In any case, I'm sending this from the yahoo-groups web interface in
                      > Firefox 2. Sorry for all the confusion Lee. Here's what I intended to
                      > send originally (hope it comes through OK):
                      >
                      > ======= (one line)
                      > ^!replace "<strong>Details:</strong>.*\*(.*)" >> "<strong>Date
                      > $1:</strong>" rwasi
                      > ======= (end one line)
                      > There are only three asterisks in the above, a dot-star, a back-slash
                      > star and another dot_star in parentheses!
                      >
                      > --- In ntb-clips@yahoogroups.com, "Sheri" <silvermoonwoman@...> wrote:
                      >> Hi Alec,
                      >>
                      >> When NoteTab gives a regex error, it is only ever referring to the
                      >> search side of a replace command.
                      >>
                      >> You have some unescaped asterisks there, especially the first
                      >> character. I haven't tested it, but it looks like a problem to me:
                      >>
                      >>> "*<strong>Details:</strong>*.*\*(.*)"
                      >> Regards,
                      >> Sheri
                      >>
                      >
                      >
                      >
                      >
                      > Fookes Software: http://www.fookes.us, http://www.fookes.com
                      > Fookes Software Mailing Lists: http://www.fookes.us/maillist.htm
                      >
                      > Yahoo! Groups Links
                      >
                      >
                      >
                      >
                    • Lee Underwood
                      Alec, This works except it includes the entire rest of the portion (making it all bold). Here is a sample of what I have to change (portions to be changed are
                      Message 10 of 12 , Jan 8, 2007
                        Alec,

                        This works except it includes the entire rest of the portion (making
                        it all bold). Here is a sample of what I have to change (portions to
                        be changed are in red):

                        <strong>Title:</strong> <a name="Credit_Card_Number_Validation"
                        href="http://javascript.internet.com/forms/credit-card-number-validation.html">Credit
                        Card Number Validation</a><br><strong>Contributor:</strong> David
                        Leppek</a> <br><strong>Contributor URL:</strong> <a
                        href="https://www.azcode.com/Mod10">https://www.azcode.com/Mod10</a><br><strong>Details:</strong>
                        4.97 KB * Uploaded November 7
                        2005<br><strong>Description:</strong> Determine if a credit card
                        number could be valid before submitting it for real-time online
                        authentication. Based on ANSI X4.13, the LUHN formula, aka the Mod 10
                        algorithm is used to validate accurate credit card numbers. Heavily
                        commented.</p><p class="listingalign" align="right">[ <a
                        href="http://javascript.internet.com/forms/credit-card-number-validation.html#source">Get
                        Source Code</a> ]
                        <hr noshade size="2">


                        Here is what I want to change it to:


                        <strong>Title:</strong> <a name="Credit_Card_Number_Validation"
                        href="http://javascript.internet.com/forms/credit-card-number-validation.html">Credit
                        Card Number Validation</a><br><strong>Contributor:</strong> David
                        Leppek</a> <br><strong>Contributor URL:</strong> <a
                        href="https://www.azcode.com/Mod10">https://www.azcode.com/Mod10</a><br><strong>Date
                        Uploaded:</strong> November 7 2005<br><strong>Description:</strong>
                        Determine if a credit card number could be valid before submitting it
                        for real-time online authentication. Based on ANSI X4.13, the LUHN
                        formula, aka the Mod 10 algorithm is used to validate accurate credit
                        card numbers. Heavily commented.</p>
                        <hr noshade size="2">



                        I hope that a bit more clearer. I tried changing yours but I haven't
                        a clue. Once I get this done I'm jumping in full-speed into RegEx.
                        It's kind of like when I was a kid and learning math, it took a bit
                        and then, bam! I got it!

                        Thanks for your help.

                        Lee



                        On 1/4/2007 08:49 PM, Alec Burgess wrote:
                        ........................................................

                        >Sheri,Lee: It looks like Thunderbird was munging what I sent (I think
                        >recognizing the strong tag in angle brackets and trying to "help" by
                        >putting the asterisks around them (the normal way to signal emphasis
                        >when sending text email) (underlines similarly are used to mark
                        >underlines and slashes to mark italics)
                        >
                        >In any case, I'm sending this from the yahoo-groups web interface in
                        >Firefox 2. Sorry for all the confusion Lee. Here's what I intended to
                        >send originally (hope it comes through OK):
                        >
                        >======= (one line)
                        >^!replace "<strong>Details:</strong>.*\*(.*)" >> "<strong>Date
                        >$1:</strong>" rwasi
                        >======= (end one line)
                        >There are only three asterisks in the above, a dot-star, a back-slash
                        >star and another dot_star in parentheses!
                        >
                        ........................................................

                        [Non-text portions of this message have been removed]
                      • Sheri
                        Try it this way: ^!Replace (?s)( .*?)Details:.*?( ).+?(Uploaded) $1Date $3$2 RAWS0 can also be written so it defaults to Ungreedy to
                        Message 11 of 12 , Jan 8, 2007
                          Try it this way:

                          ^!Replace "(?s)(<strong>.*?)Details:.*?(</strong>).+?(Uploaded)" >>
                          "$1Date $3$2" RAWS0

                          can also be written so it defaults to Ungreedy to avoid needing the
                          question marks:

                          ^!Replace "(?sU)(<strong>.*)Details:.*(</strong>).+(Uploaded)" >>
                          "$1Date $3$2" RAWS0

                          Regards,
                          Sheri
                        • Lee Underwood
                          Sheri, Thanks! That works great! I was also able to adapt it for another change. I ll take a dissect it to get a better understanding. Thanks again. Lee On
                          Message 12 of 12 , Jan 9, 2007
                            Sheri,

                            Thanks! That works great! I was also able to adapt it for another
                            change. I'll take a dissect it to get a better understanding.

                            Thanks again.

                            Lee




                            On 1/8/2007 06:55 PM, Sheri wrote:
                            ........................................................

                            >Try it this way:
                            >
                            >^!Replace "(?s)(<strong>.*?)Details:.*?(</strong>).+?(Uploaded)" >>
                            >"$1Date $3$2" RAWS0
                            >
                            >can also be written so it defaults to Ungreedy to avoid needing the
                            >question marks:
                            >
                            >^!Replace "(?sU)(<strong>.*)Details:.*(</strong>).+(Uploaded)" >>
                            >"$1Date $3$2" RAWS0
                            >
                            >Regards,
                            >Sheri
                            ........................................................
                          Your message has been successfully submitted and would be delivered to recipients shortly.