• Login
Community
  • Login

Zeilenanfang mit Großbuchstaben

Scheduled Pinned Locked Moved General Discussion
12 Posts 3 Posters 865 Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P
    PeterJones @Klaus-Peter Haufe
    last edited by Sep 7, 2021, 2:41 PM

    @Klaus-Peter-Haufe ,

    Auf Englisch, bitte.

    The official language of this Community forum is English. If you need help to translate from your preferred language into English before posting, you can paste your German (or other preferred language) into translate.google.com or https://www.deepl.com/en/translator to get the English, then paste the result into your post in the forum (if you’d like, you can include both the original text and the translation; but every post should have the English version); similarly, you can use those same tools to translate replies back from English into your preferred language.

    On to your question:

    Hello, I am working on a very long document (Bible text). The lines sometimes start with lowercase letters. But I want every word to start with a capital letter at the beginning of the line. How can I achieve this?

    FIND = (?-i)^\l
    REPLACE = \u$0
    SEARCH MODE = regular expression

    Concepts:

    • search modifiers (force case sensitive) = https://npp-user-manual.org/docs/searching/#search-modifiers
    • anchors (match start of line) = https://npp-user-manual.org/docs/searching/#anchors
    • character classes (find lowercase letter) = https://npp-user-manual.org/docs/searching/#character-classes
    • substitution escape sequences (make next charater uppercase, and include the entire match from the FIND) = https://npp-user-manual.org/docs/searching/#substitution-escape-sequences
    1 Reply Last reply Reply Quote 0
    • K
      Klaus-Peter Haufe
      last edited by Sep 7, 2021, 3:05 PM

      Thank you!

      1 Reply Last reply Reply Quote 0
      • K
        Klaus-Peter Haufe
        last edited by Sep 7, 2021, 3:48 PM

        Unfortunately, I have had no success so far. The error message appeared:

        Invalid back reference: specified capturing group does not exist. The error occurred while parsing the regular expression: ‘(?-i)^>>>HERE>>>\1’.

        Peter

        P 1 Reply Last reply Sep 7, 2021, 3:59 PM Reply Quote 0
        • P
          PeterJones @Klaus-Peter Haufe
          last edited by PeterJones Sep 7, 2021, 3:59 PM Sep 7, 2021, 3:59 PM

          @Klaus-Peter-Haufe

          That’s a lowercase L, not a digit 1.

          You can copy/paste from the previous post to get the exact text to use

          1 Reply Last reply Reply Quote 0
          • K
            Klaus-Peter Haufe
            last edited by Sep 8, 2021, 6:52 AM

            @PeterJones said in Zeilenanfang mit Großbuchstaben:

            (?-i)^\l

            Now appears as error message: Could not find text “(?-i)^\l”

            G 1 Reply Last reply Sep 8, 2021, 7:27 AM Reply Quote 0
            • G
              gerdb42 @Klaus-Peter Haufe
              last edited by Sep 8, 2021, 7:27 AM

              @Klaus-Peter-Haufe

              Could it be that your lines contain Whitespace at the very left? If that is the case your search expression should be:

              (?-i)^\s*\l

              For questions like this it always helps if you can provide some sample text of the original and expected outcome.

                 Please put the text in code blocks by putting three backticks (```) above and below to avoid formatting by the forum engine.
              
              1 Reply Last reply Reply Quote 0
              • K
                Klaus-Peter Haufe
                last edited by Sep 8, 2021, 8:36 AM

                Also the expression (?-i)^\s*\l does not bring success. But your question made me realize my mistake. I had not said that each line begins with the specification of a Bible passage (e.g. Deu 21:16) and 2 blanks.

                Here is an example:

                
                And so the result shall be:
                
                ```Deu 21:16  An dem Tage nun, wo er seine Söhne zu Erben macht dessen, was sein ist „,
                
                Sorry!!!
                1 Reply Last reply Reply Quote 0
                • K
                  Klaus-Peter Haufe
                  last edited by Sep 8, 2021, 8:39 AM

                  The example:

                  
                  And so the result shall be:
                  ```Deu 21:16  An dem Tage nun, wo er seine Söhne zu Erben macht dessen, was sein ist„,
                  1 Reply Last reply Reply Quote 0
                  • K
                    Klaus-Peter Haufe
                    last edited by Sep 8, 2021, 8:41 AM

                    
                    ```Deu 21:16  An dem Tage nun, wo er seine Söhne zu Erben macht dessen, was sein ist„,
                    P 1 Reply Last reply Sep 8, 2021, 1:27 PM Reply Quote 0
                    • P
                      PeterJones @Klaus-Peter Haufe
                      last edited by PeterJones Sep 8, 2021, 1:27 PM Sep 8, 2021, 1:27 PM

                      @Klaus-Peter-Haufe

                      I had not said that each line begins with the specification of a Bible passage (e.g. Deu 21:16) and 2 blanks.

                      Yes, if you don’t describe the data properly, we cannot give you a valid regular expression.

                      You still don’t seem to be giving us valid example data, because the examples you are showing all have the first word after the verse number already capitalized.

                      But if you have

                      Deu 21:16  an dem Tage nun, wo er seine Söhne zu Erben macht dessen, was sein ist
                      

                      and want

                      Deu 21:16  An dem Tage nun, wo er seine Söhne zu Erben macht dessen, was sein ist
                      

                      Then, I am going to apply the rule: look for a colon followed by one or more digits followed by two spaces; if the next character is lowercase, then change it to uppercase. To do this, I will put the colon, numbers, and spaces in capture group 1 and the lowercase letter in capture group 2 (there are other possibilities, but I think this is easier for newbies to understand than the capture-reset command)

                      • FIND = (?-i)(:\d+\h\h)(\l)
                      • REPLACE = $1\u$2
                      • SEARCH MODE = regular expression

                      ----

                      Do you want regex search/replace help? Then please be patient and polite, show some effort, and be willing to learn; answer questions and requests for clarification that are made of you. All example text should be marked as literal text using the </> toolbar button or manual Markdown syntax. To make regex in red (and so they keep their special characters like *), use backticks, like `^.*?blah.*?\z`. Screenshots can be pasted from the clipboard to your post using Ctrl+V to show graphical items, but any text should be included as literal text in your post so we can easily copy/paste your data. Show the data you have and the text you want to get from that data; include examples of things that should match and be transformed, and things that don’t match and should be left alone; show edge cases and make sure you examples are as varied as your real data. Show the regex you already tried, and why you thought it should work; tell us what’s wrong with what you do get. Read the official NPP Searching / Regex docs and the forum’s Regular Expression FAQ. If you follow these guidelines, you’re much more likely to get helpful replies that solve your problem in the shortest number of tries.

                      1 Reply Last reply Reply Quote 1
                      • K
                        Klaus-Peter Haufe
                        last edited by Sep 8, 2021, 2:22 PM

                        Thank you very much, this is exactly what I want!

                        1 Reply Last reply Reply Quote 0
                        11 out of 12
                        • First post
                          11/12
                          Last post
                        The Community of users of the Notepad++ text editor.
                        Powered by NodeBB | Contributors