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

Re: [Clip] Upper & Low cases

Expand Messages
  • Axel Berger
    ... That s a difficult one, as Regex does not support functions and normal replace can t find arbitrary letters. I have solved this kind of problem ... ^!Find
    Message 1 of 15 , Aug 11, 2009
    • 0 Attachment
      "c.brito78" wrote:
      > 1. The first character of a new paragraph (if either Low or Upper case)

      That's a difficult one, as Regex does not support functions and normal
      replace can't find arbitrary letters. I have solved this kind of problem
      with a ^!Find followed by an ^!Insert working on the found part:

      :loop
      ^!Find "^(.)" HRS1
      ;^!Continue
      ^!IfError clean
      ^!InsertText ^$StrUpper("^$GetSelection$")$
      ^!Goto loop
      :clean

      This is untested, but I have used the same technique with a different
      function.

      Axel
    • John Shotsky
      I routinely do something similar This could be made more efficient by only working on the lower case letters: (Tested) ^!Jump Doc_Start ... ;^!Setdebug ON
      Message 2 of 15 , Aug 11, 2009
      • 0 Attachment
        I routinely do something similar This could be made more efficient by only working on the lower case letters: (Tested)

        ^!Jump Doc_Start
        :Loop
        ;^!Setdebug ON
        ^!Find "^([a-z])" RS
        ^!Iferror Done
        ^!InsertText ^$StrUpper(^$StrIndex("^$GetSelection$";1)$)$
        ^!Goto Loop
        :Done

        John

        From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf Of Axel Berger
        Sent: Tuesday, August 11, 2009 06:41
        To: ntb-clips@yahoogroups.com
        Subject: Re: [Clip] Upper & Low cases


        "c.brito78" wrote:
        > 1. The first character of a new paragraph (if either Low or Upper case)

        That's a difficult one, as Regex does not support functions and normal
        replace can't find arbitrary letters. I have solved this kind of problem
        with a ^!Find followed by an ^!Insert working on the found part:

        :loop
        ^!Find "^(.)" HRS1
        ;^!Continue
        ^!IfError clean
        ^!InsertText ^$StrUpper("^$GetSelection$")$
        ^!Goto loop
        :clean

        This is untested, but I have used the same technique with a different
        function.

        Axel



        [Non-text portions of this message have been removed]
      • c.brito78
        Hi Axel, Worked. Thanks again. Best regard, C Brito
        Message 3 of 15 , Aug 11, 2009
        • 0 Attachment
          Hi Axel,

          Worked. Thanks again.

          Best regard,
          C Brito
          ---------------------------------------



          --- In ntb-clips@yahoogroups.com, Axel Berger <Axel-Berger@...> wrote:
          >
          > "c.brito78" wrote:
          > > 1. The first character of a new paragraph (if either Low or Upper case)
          >
          > That's a difficult one, as Regex does not support functions and normal
          > replace can't find arbitrary letters. I have solved this kind of problem
          > with a ^!Find followed by an ^!Insert working on the found part:
          >
          > :loop
          > ^!Find "^(.)" HRS1
          > ;^!Continue
          > ^!IfError clean
          > ^!InsertText ^$StrUpper("^$GetSelection$")$
          > ^!Goto loop
          > :clean
          >
          > This is untested, but I have used the same technique with a different
          > function.
          >
          > Axel
          >
        • Axel Berger
          ... Glad to hear it. Please also look at John s solution, which in some ways is more elegant than mine. In essence it s the same of course. Axel
          Message 4 of 15 , Aug 11, 2009
          • 0 Attachment
            "c.brito78" wrote:
            > Worked. Thanks again.

            Glad to hear it. Please also look at John's solution, which in some ways
            is more elegant than mine. In essence it's the same of course.

            Axel
          • Jeff
            Something like this in a clip? ^!SELECT Paragraph Start ^!KEYBOARD SHIFT+CTRL+K
            Message 5 of 15 , Aug 11, 2009
            • 0 Attachment
              Something like this in a clip?

              ^!SELECT Paragraph Start
              ^!KEYBOARD SHIFT+CTRL+K
            • c.brito78
              Friends Alex, John, Jeff, thanks. I tested the Alex suggestion. Worked fine, if I have all paragraphs like: paragraph 1, etc etc etc. paragraph 2, etc etc etc.
              Message 6 of 15 , Aug 12, 2009
              • 0 Attachment
                Friends Alex, John, Jeff, thanks.

                I tested the Alex suggestion. Worked fine, if I have all paragraphs like:

                paragraph 1, etc etc etc.
                paragraph 2, etc etc etc.
                paragraph 3, etc etc etc.

                But my paragraphs are separated by two carriage returns, like:

                paragraph 1, etc etc etc.

                paragraph 2, etc etc etc.

                paragraph 3, etc etc etc.

                And I do not know how to include the two carriage returns to the Alex regex.

                Thanks again

                Brito



                --- In ntb-clips@yahoogroups.com, "John Shotsky" <jshotsky@...> wrote:
                >
                > I routinely do something similar This could be made more efficient by only working on the lower case letters: (Tested)
                >
                > ^!Jump Doc_Start
                > :Loop
                > ;^!Setdebug ON
                > ^!Find "^([a-z])" RS
                > ^!Iferror Done
                > ^!InsertText ^$StrUpper(^$StrIndex("^$GetSelection$";1)$)$
                > ^!Goto Loop
                > :Done
                >
                > John
                >
                > From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf Of Axel Berger
                > Sent: Tuesday, August 11, 2009 06:41
                > To: ntb-clips@yahoogroups.com
                > Subject: Re: [Clip] Upper & Low cases
                >
                >
                > "c.brito78" wrote:
                > > 1. The first character of a new paragraph (if either Low or Upper case)
                >
                > That's a difficult one, as Regex does not support functions and normal
                > replace can't find arbitrary letters. I have solved this kind of problem
                > with a ^!Find followed by an ^!Insert working on the found part:
                >
                > :loop
                > ^!Find "^(.)" HRS1
                > ;^!Continue
                > ^!IfError clean
                > ^!InsertText ^$StrUpper("^$GetSelection$")$
                > ^!Goto loop
                > :clean
                >
                > This is untested, but I have used the same technique with a different
                > function.
                >
                > Axel
                >
                >
                >
                > [Non-text portions of this message have been removed]
                >
              • Axel Berger
                ... That oughtn t matter. I presume what you really mean is, there are single carriage returns that are not paragraphs and should not be modified. Please try
                Message 7 of 15 , Aug 12, 2009
                • 0 Attachment
                  "c.brito78" wrote:
                  > But my paragraphs are separated by two carriage returns,

                  That oughtn't matter. I presume what you really mean is, there are
                  single carriage returns that are not paragraphs and should not be
                  modified.

                  Please try this:

                  ^!Jump Doc_Start
                  :loop
                  ^!Find "(?s)\R\R([a-z])" RS1
                  ;^!Continue
                  ^!IfError clean
                  ^!InsertText ^$StrUpper("^$GetSelection$")$
                  ^!Goto loop
                  :clean

                  By the way, it's Axel not Alex, please.

                  Axel
                • c.brito78
                  Sorry, Axel. It is because I have friends that are Alex (Alexandre). I will test. Thanks!
                  Message 8 of 15 , Aug 12, 2009
                  • 0 Attachment
                    Sorry, Axel. It is because I have friends that are Alex (Alexandre).

                    I will test.

                    Thanks!


                    --- In ntb-clips@yahoogroups.com, Axel Berger <Axel-Berger@...> wrote:
                    >
                    > "c.brito78" wrote:
                    > > But my paragraphs are separated by two carriage returns,
                    >
                    > That oughtn't matter. I presume what you really mean is, there are
                    > single carriage returns that are not paragraphs and should not be
                    > modified.
                    >
                    > Please try this:
                    >
                    > ^!Jump Doc_Start
                    > :loop
                    > ^!Find "(?s)\R\R([a-z])" RS1
                    > ;^!Continue
                    > ^!IfError clean
                    > ^!InsertText ^$StrUpper("^$GetSelection$")$
                    > ^!Goto loop
                    > :clean
                    >
                    > By the way, it's Axel not Alex, please.
                    >
                    > Axel
                    >
                  • Axel Berger
                    ... In that version I have used John s Find. I just realized, that this will not get umlauts or any other kind of accented letter. So in hindsight I ll go back
                    Message 9 of 15 , Aug 12, 2009
                    • 0 Attachment
                      "c.brito78" wrote:
                      > I will test.

                      In that version I have used John's Find. I just realized, that this will
                      not get umlauts or any other kind of accented letter. So in hindsight
                      I'll go back and recommend my older version:

                      ^!Find "(?s)\R\R(.)" RS1

                      Axel
                    • John Shotsky
                      The clip I provided ignores blank lines. It only finds lower case letters in the first position. John From: ntb-clips@yahoogroups.com
                      Message 10 of 15 , Aug 12, 2009
                      • 0 Attachment
                        The clip I provided ignores blank lines. It only finds lower case letters in the first position.
                        John

                        From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf Of c.brito78
                        Sent: Wednesday, August 12, 2009 07:05
                        To: ntb-clips@yahoogroups.com
                        Subject: [Clip] Re: Upper & Low cases


                        Friends Alex, John, Jeff, thanks.

                        I tested the Alex suggestion. Worked fine, if I have all paragraphs like:

                        paragraph 1, etc etc etc.
                        paragraph 2, etc etc etc.
                        paragraph 3, etc etc etc.

                        But my paragraphs are separated by two carriage returns, like:

                        paragraph 1, etc etc etc.

                        paragraph 2, etc etc etc.

                        paragraph 3, etc etc etc.

                        And I do not know how to include the two carriage returns to the Alex regex.

                        Thanks again

                        Brito

                        --- In ntb-clips@yahoogroups.com <mailto:ntb-clips%40yahoogroups.com> , "John Shotsky" <jshotsky@...> wrote:
                        >
                        > I routinely do something similar This could be made more efficient by only working on the lower case letters: (Tested)
                        >
                        > ^!Jump Doc_Start
                        > :Loop
                        > ;^!Setdebug ON
                        > ^!Find "^([a-z])" RS
                        > ^!Iferror Done
                        > ^!InsertText ^$StrUpper(^$StrIndex("^$GetSelection$";1)$)$
                        > ^!Goto Loop
                        > :Done
                        >
                        > John
                        >
                        > From: ntb-clips@yahoogroups.com <mailto:ntb-clips%40yahoogroups.com> [mailto:ntb-clips@yahoogroups.com
                        <mailto:ntb-clips%40yahoogroups.com> ] On Behalf Of Axel Berger
                        > Sent: Tuesday, August 11, 2009 06:41
                        > To: ntb-clips@yahoogroups.com <mailto:ntb-clips%40yahoogroups.com>
                        > Subject: Re: [Clip] Upper & Low cases
                        >
                        >
                        > "c.brito78" wrote:
                        > > 1. The first character of a new paragraph (if either Low or Upper case)
                        >
                        > That's a difficult one, as Regex does not support functions and normal
                        > replace can't find arbitrary letters. I have solved this kind of problem
                        > with a ^!Find followed by an ^!Insert working on the found part:
                        >
                        > :loop
                        > ^!Find "^(.)" HRS1
                        > ;^!Continue
                        > ^!IfError clean
                        > ^!InsertText ^$StrUpper("^$GetSelection$")$
                        > ^!Goto loop
                        > :clean
                        >
                        > This is untested, but I have used the same technique with a different
                        > function.
                        >
                        > Axel
                        >
                        >
                        >
                        > [Non-text portions of this message have been removed]
                        >



                        [Non-text portions of this message have been removed]
                      • John Shotsky
                        You re right. Since my work deals with recipes, I encounter many such letters. Have not found a good solution other than either listing them, or including some
                        Message 11 of 15 , Aug 12, 2009
                        • 0 Attachment
                          You're right. Since my work deals with recipes, I encounter many such letters. Have not found a good solution other than
                          either listing them, or including some mini-ranges to capture them.

                          However, almost never does a line start with an accented letter, and usually, upper case letters should not be accented
                          anyway.

                          Then, there could be a problem if a line starts with a quote, double quote or a paren and is followed by a lower case
                          letter -

                          In the segment below, I'd use \R+ instead of \R\R, since I don't think there is a rule that there must be a blank line
                          between all other lines, and it will also miss the first row, if it is lower case, unless a leading blank line is added.
                          John

                          From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf Of Axel Berger
                          Sent: Wednesday, August 12, 2009 07:46
                          To: ntb-clips@yahoogroups.com
                          Subject: Re: [Clip] Re: Upper & Low cases


                          "c.brito78" wrote:
                          > I will test.

                          In that version I have used John's Find. I just realized, that this will
                          not get umlauts or any other kind of accented letter. So in hindsight
                          I'll go back and recommend my older version:

                          ^!Find "(?s)\R\R(.)" RS1

                          Axel



                          [Non-text portions of this message have been removed]
                        • Axel Berger
                          ... Sorry, but in this case I claim superior knowledge as a German: Ärger, Ångstrøm, Über (capitalized as the first word of a sentence), Ölsand ... If my
                          Message 12 of 15 , Aug 12, 2009
                          • 0 Attachment
                            John Shotsky wrote:
                            > and usually, upper case letters should not be accented anyway.

                            Sorry, but in this case I claim superior knowledge as a German: Ärger,
                            Ångstrøm, Über (capitalized as the first word of a sentence), Ölsand ...
                            If my French were acceptable, I'm sure I'd find many more examples there
                            too.

                            > Then, there could be a problem if a line starts with a quote,
                            > double quote or a paren and is followed by a lower case letter

                            True. We don't know how paragraphs and thus presumably sentences came to
                            be uncapitalized in the first place, but C. specified "first character"
                            in his request.

                            > In the segment below, I'd use \R+ instead of \R\R, since I don't
                            > think there is a rule that there must be a blank line

                            My understandig was that line feeds that are not paragraphs were the
                            issue here and should not be modified. As you noted yourself "The clip I
                            provided ignores blank lines."

                            Axel
                          • Sheri
                            Just another possibility: This one loops from the top finding only lower case letters as the first character of a line (possibly preceeded by a double quote)
                            Message 13 of 15 , Aug 12, 2009
                            • 0 Attachment
                              Just another possibility: This one loops from the top finding only lower case letters as the first character of a line (possibly preceeded by a double quote) and capitalizes them. Works for plain and accented latin characters.

                              ^!Jump Doc_start
                              :loop
                              ^!Find "^\x22?\K\p{Ll}" RS
                              ^!Iferror Out
                              ^!Menu Modify/Text Case/Upper Case
                              ^!Goto loop
                              :Out

                              Regards,
                              Sheri
                            • ebbtidalflats
                              I d like to offer my 2 cents worth (or as Axel would say, his mustard): To change the case of EVERY first character of every line, WITHOUT LOOPING, use the
                              Message 14 of 15 , Aug 15, 2009
                              • 0 Attachment
                                I'd like to offer my 2 cents worth (or as Axel would say, his mustard):

                                To change the case of EVERY first character of every line,
                                WITHOUT LOOPING, use the BLOCK mode and a helper file,
                                something like (untested):

                                ^!SetWordWrap OFF
                                ^!SelectTo ^$GetLineCount$:2
                                ^!Menu Modify/Block/Cut
                                ^!Set %orig%=^$GetDocIndex$
                                ^!Menu File/New
                                ^!Set %helper%=^$GetDocIndex$
                                ^!Menu Edit/Paste
                                ^!Menu Modify/"Text case"/"Upper case"
                                ^!Select All
                                ^!Menu Modify Block/Copy
                                ^!SetDocIndex ^%orig%
                                ^!SetCursor 1:1
                                ^!Menu Block/Paste
                                ^!DestroyDoc ^$GetDocName(^%helper%)$

                                Anybody care to time executions of the various solutions?

                                Cheers,

                                Eb


                                --- In ntb-clips@yahoogroups.com, Axel Berger <Axel-Berger@...> wrote:
                                >
                                > John Shotsky wrote:
                                > > and usually, upper case letters should not be accented anyway.
                                >
                                > Sorry, but in this case I claim superior knowledge as a German: Ärger,
                                > Ångstrøm, Über (capitalized as the first word of a sentence), Ölsand
                              Your message has been successfully submitted and would be delivered to recipients shortly.