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

RE: [Clip] Dot matches newline ON or OFF (was Re: Non printing characters.)

Expand Messages
  • John Shotsky
    The first thought is to post the text you are working with, as previously mentioned. We aren t going to build your test case FOR YOU. If you want help, be
    Message 1 of 16 , Apr 19 5:42 PM
    View Source
    • 0 Attachment
      The first thought is to post the text you are working with, as previously mentioned. We aren't going to build your test case FOR
      YOU. If you want help, be SPECIFIC.

      Your 'example' shows a number of characters that can't be used in regex without escaping them, and as they are, and that would NEVER
      have worked. Specifically, if you have double quotes in the find, you have to escape them. Still, you have not made it clear what
      you are doing, since there is no block of your target text and no clear example of your find/replace text. Almost ALL of us can make
      it work, but you are trying to make us guess what your text looks like.

      Regards,
      John
      RecipeTools Web Site: <http://recipetools.gotdns.com/> http://recipetools.gotdns.com/
      John's Mags Yahoo Group: <http://groups.yahoo.com/group/johnsmags/> http://groups.yahoo.com/group/johnsmags/

      From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf Of hitch@...
      Sent: Friday, April 19, 2013 17:19
      To: ntb-clips@yahoogroups.com
      Subject: [Clip] Dot matches newline ON or OFF (was Re: Non printing characters.)




      Axel:

      I posted the description, so you'd know what I did as it was being entered. I did not realize that what I'd pasted would be unclear
      to anyone here. To be clear, in the "search for" field, I used:

      <italic span>(.*?)</span>

      With the named span inserted where the "italic span" text is now. When I say that this is a 'clip,' I keep it stored in my clips,
      but as it's never the same (the name and other material for the span can be ANYTHING that somebody in their brain thought up, any
      name for the span, any font, etc.), it's not viable as a regular "clip." I mean, I could automate it, to the pasting, but...why?

      So, I copy-and-paste the name of the span, e.g.:

      <span style='font-family:"Times New Roman Italic","serif"'>(.*?)</span>

      then select regex, and then, in the replace box, I've simply always put:

      <i>$1</i>

      ...which has, to date, *always* worked. Now, I know that I've got "regex" selected, because it's finding the FIND. If regex were not
      selected, it would not be. After a post here, I added

      (?s)

      to the front of the search, as I was suddenly encountering issues with the search not working due to non-printing chars. (This has
      always worked, non-printing chars or not, before, BTW, without the (?s), FWIW).

      And NOW, the replace is replacing what *should* be something like

      <i>and they lived happily ever after</i>

      post-regex, to:

      <i>$1</i>

      literally. As if it's a regular s&r, not regex. Yes, I tried putting parentheticals around the $1, but that did not change the
      result.

      Does anyone have any thoughts? Thank you.

      Hitch

      --- In ntb-clips@yahoogroups.com <mailto:ntb-clips%40yahoogroups.com> , Axel Berger <Axel-Berger@...> wrote:
      >
      > hitch@... wrote:
      > > Search: <italic span>(.*?)</span> Replace: <i>$1</i>
      >
      > > this clip has been stored in my library for ~2 years now
      >
      > As above it's no clip. When using those two terms in the dialogue you
      > need to select regular expressions. There was a recent change there,
      > regex used to be a checkbox and is now part of a dropdown.
      >
      > If it is a clip please post that as-is and completely and not some
      > decription of it.
      >
      > Axel
      >



      [Non-text portions of this message have been removed]
    • Axel Berger
      ... That s what I assumed. Please accept that using the dialogue is NOT a clip. ... That one I don t quite get. You use the clipbook to store stuff which you
      Message 2 of 16 , Apr 20 12:55 AM
      View Source
      • 0 Attachment
        hitch@... wrote:
        > I did not realize that what I'd pasted would be unclear to anyone
        > here. To be clear, in the "search for" field, I used:

        That's what I assumed. Please accept that using the dialogue is NOT a
        clip.

        > When I say that this is a 'clip,' I keep it stored in my clips

        That one I don't quite get. You use the clipbook to store stuff which
        you then copy and paste into a dialogue? If you were to write

        ^!Replace "<span[^>]*>(.*?)</span>" >> "<i>$1</i>" R

        You could just click on that and be done.

        > Now, I know that I've got "regex" selected, because it's finding
        > the FIND. If regex were not selected, it would not be.

        Yes, agree.

        > Does anyone have any thoughts? Thank you.

        I have to think about that one.

        Axel
      • Axel Berger
        ... Alright, I ve done it. Using the dialogue like you do I have taken the Text: and they lived
        Message 3 of 16 , Apr 20 1:23 AM
        View Source
        • 0 Attachment
          Axel Berger wrote:
          > I have to think about that one.

          Alright, I've done it. Using the dialogue like you do I have taken the

          Text:
          <span style='font-family:"Times New Roman Italic","serif"'>and they
          lived happily ever after</span>

          Find:
          <span[^>]*>(.*?)</span>

          Replace:
          <i>$1</i>

          and got:
          <i>and they lived happily ever after</i>

          I've no idea what may be wrong your side. But it has happened to all of
          us, that we looked and looked and just did not see some embarrassing
          typo or other. So as a general rule DO NOT type stuff into your mails
          but always copy and paste even the simplest things. It MUST be something
          simple and obvious, I just can't guess what it may be.

          Axel
        • kahitch
          Axel: ... Without modifying the spanned aspect every time. The spans I fix are each completely different (to each document, not unique, all of them, to each
          Message 4 of 16 , Apr 20 4:18 AM
          View Source
          • 0 Attachment
            Axel:

            I'm no regex expert, and don't claim to be, but I cannot use this:

            > ^!Replace "<span[^>]*>(.*?)</span>" >> "<i>$1</i>" R

            Without modifying the spanned aspect every time. The spans I "fix" are each completely different (to each document, not unique, all of them, to each other). In word processing environments, each individual user (every single person) could name that span something completely different, use a different font, and have a different fallback font. Thusly, this span (which as been the subject of this discussion):

            <span style='font-family:"Times New Roman Italic","serif"'>

            Is unique ONLY to this particular document. Next time, it might be:

            <span style='font-family:"Helvetica","sans-serif"'>

            It's never the same information inside the span. In fact, because of the cruft that all the word-processing programs out there put out, I can have to make 3, 4 5 or more passes, because a) the spacing between elements or the text inside the span will be different; b) the name of the span will be different, or c) any number of other things will be different, all simply to do nothing more than simply *italicize text.* And this is in a single document.

            And I cannot simply regex *all* the spans, because some goodly number of the spans--at least half--are legit, and shouldn't be removed or altered. Believe me, if the spans weren't different each and every time, OF COURSE I would create a clip that I could deploy with a click. I do have "actual" clips like that; those that replace curly quotes with straight, Fix apostrophes, etc. But that only works when the material searched for is always the same. In this case, not only is it not "always" the same, it is NEVER the same, and I don't have the luxury of nuking the precisely 3,937 instances of spans in the HTML document when only some 2-300 of them need to be changed.

            And for the other posters: Yes, I've escaped the special characters. Here's a sample paragraph from the copyrighted text I've been working with:

            <p class=BodyA style='margin-bottom:3.0pt;text-align:justify;text-indent:.25in'><span
            style='font-family:"Times New Roman","serif"'>Emory told them about her long
            day -- four photo shoots in three different locations, and one cranky baby who
            threw up on her.  She found time to squeeze in an occasional text with Mason,
            who was bothered by the tone of the Seahawks meeting -- he didn't like to be
            doubted and hated having his divorce thrown in his face.  Wesley said that was
            good news -- it was unlikely Mason would end up there -- but Emory couldn't
            help thinking it was still a possibility.  </span><span style='font-family:
            "Times New Roman Italic","serif"'>How would that work? </span><span
            style='font-family:"Times New Roman","serif"'> </span></p>

            The ONE span with the <span style='font-family:"Times New Roman Italic","serif"'> throughout the document, which occurs some several hundred times, is what I'm trying to change to, very simply, this:

            <i>How would that work? </i>

            But the clip that I have previously pasted here several times, which has previously worked without a hiccup, now does not. I have added the previously discussed bit, to resolve the non-printing characters, and, again, this is the "saved un-clip" that I've been using for two years sans issues, but now seems to have gone utterly wonky for no apparent reason (please infer that the "search" etc, are NOT part of the actual "clip," thank you); only what you see between opening and closing brackets is actually part of what goes in the regex search and replace boxes.

            Search: <italic span>(.*?)</span> Replace: <i>$1</i>

            Thank you. Again.

            Hitch




            --- In ntb-clips@yahoogroups.com, Axel Berger <Axel-Berger@...> wrote:
            >
            > hitch@... wrote:
            > > I did not realize that what I'd pasted would be unclear to anyone
            > > here. To be clear, in the "search for" field, I used:
            >
            > That's what I assumed. Please accept that using the dialogue is NOT a
            > clip.
            >
            > > When I say that this is a 'clip,' I keep it stored in my clips
            >
            > That one I don't quite get. You use the clipbook to store stuff which
            > you then copy and paste into a dialogue? If you were to write
            >
            > ^!Replace "<span[^>]*>(.*?)</span>" >> "<i>$1</i>" R
            >
            > You could just click on that and be done.
            >
            > > Now, I know that I've got "regex" selected, because it's finding
            > > the FIND. If regex were not selected, it would not be.
            >
            > Yes, agree.
            >
            > > Does anyone have any thoughts? Thank you.
            >
            > I have to think about that one.
            >
            > Axel
            >
          • Axel Berger
            ... Are those the same? What I tend to do in cases like that is to first mask the things I want to keep, by e.g. renaming to
            Message 5 of 16 , Apr 20 6:36 AM
            View Source
            • 0 Attachment
              hitch@... wrote:
              > And I cannot simply regex *all* the spans, because some goodly
              > number of the spans--at least half--are legit, and shouldn't be
              > removed or altered.

              Are those the same? What I tend to do in cases like that is to first
              mask the things I want to keep, by e.g. renaming to <xspan, alter
              everything else, and rename my kept ones back.

              > Believe me, if the spans weren't different each and every time,
              > OF COURSE I would create a clip that I could deploy with a click.

              I do believe you. But as stated I have replayed what you described as
              exactly as I could and for me it worked flawlessly. Until I can
              reproduce your problem I can't begin to think of a workaround. As John
              said, give us a) a sample text, b) a find string, and c) a replace
              string that don't work and thus reproduce your problem and we can begin
              to concoct a solution.

              Until that time all I can say is, it works as it should, I don't see
              what your problem is. That is not doubting you that there is one, it's
              just being incapable of reproducing it.

              Axel
            • Art Kocsis
              ... Why is because (from what you have told us), it is a perfect application for a clip using RegEx. .* is exactly what ANYTHING that somebody in their
              Message 6 of 16 , Apr 20 8:38 AM
              View Source
              • 0 Attachment
                At 4/19/2013 05:18 PM, Hitch wrote:
                >With the named span inserted where the "italic span" text is now. When I say that this is a 'clip,' I keep it stored in my clips, but as it's never the same (the name and other material for the span can be ANYTHING that somebody in their brain thought up, any name for the span, any font, etc.), it's not viable as a regular "clip." I mean, I could automate it, to the pasting, but...why?
                >
                >So, I copy-and-paste the name of the span, e.g.:
                >
                ><span style='font-family:"Times New Roman Italic","serif"'>(.*?)</span>
                >
                >then select regex, and then, in the replace box, I've simply always put:
                >
                ><i>$1</i>


                "Why" is because (from what you have told us), it is a perfect application for a clip using
                RegEx. ".*" is exactly what "ANYTHING that somebody in their brain thought up" matches.

                ^!Replace "(?s)<span\s[^>]*?>(.*?)</span>" >> "<i>$1</i>" IHRS

                When you see a $n (n=digit), in the result it means the referenced capture substring is undefined. Note: a null string is still defined.


                Now this is very strange!! The find works fine but the replace is going bananas.
                The result of that command on your test line is:

                <i>(.*?)</i>

                The parenthesis meta characters are being treated as ordinary characters.

                Stranger still (added alternate pattern and set min capture to 1):

                ^!Replace "(?s)<span\s[^>]*?>(.+?|ZZZ)</span>" >> "<i>$1</i>" IHRS

                Applied to (added "Z" between ">" and "("):

                <span style='font-family:"Times New Roman Italic","serif"'>Z(.*?)</span>

                Still results in:

                <i>Z(.*?)</i>

                OK, full debug mode (grouped tags & escaped ">"), group debug output.

                Command (long line ahead followed by parenthesis verification):

                ^!Replace "(?s)(<span\s[^>]*?\>)(.+?|ZZZ)(</span>)" >> "\r\n\$0='$0'\r\n\$1='$1'\r\n\$2='$2'\r\n\$3='$3'\r\n" IRST
                ( )( )( | )( )

                Test string:

                <span style='font-family:"Times New Roman Italic","serif"'>Z(.*?)</span>

                Command Results:

                $0='<span style='font-family:"Times New Roman Italic","serif"'>Z(.*?)</span>'
                $1='<span style='font-family:"Times New Roman Italic","serif"'>'
                $2='Z(.*?)'
                $3='</span>'

                WIH is going on??? Same behavior with both NTS v5.8/fv & v6.2/fv.
                Why is the (.*?) pattern not being treated as a group yet the other ones are?
                This should have been a quick reply with a simple command the gremlins have attacked again.

                Art
              Your message has been successfully submitted and would be delivered to recipients shortly.