Zeilenanfang mit Großbuchstaben
Hallo, ich bearbeite ein sehr langes Dokument (Bibeltext). Die Zeilen beginnen mitunter mit Kleinbuchstaben. Doch ich möchte, dass jedes Wort am Zeilenanfang mit einem Großbuchstaben beginnt. Wie kann ich das erreichen?
Bin für jeden Tipp dankbar!
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?
SEARCH MODE = regular expression
- 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
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’.
That’s a lowercase L, not a digit 1.
You can copy/paste from the previous post to get the exact text to use
Could it be that your lines contain Whitespace at the very left? If that is the case your search expression should be:
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.
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!!!
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„,
```Deu 21:16 An dem Tage nun, wo er seine Söhne zu Erben macht dessen, was sein ist„,
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
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 =
- REPLACE =
- 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+Vto 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.
- FIND =
Thank you very much, this is exactly what I want!