How to replace uppercase letters by their lowercase counterparts? - replace

I have a big text document in which suspension points are followed by a capital letter. It should be lowercase. Now I figured to use this expression in search & replace: …\ [:upper:] which works fine to find the parts I want to replace, but when I try to do that with …\ [:lower:] I pastes literally that expression rather than the same letter but lowercase. What am I doing wrong? Thanks!

You can't use [:lower:] this way, because it's only a pattern to match the search text; it doesn't affect or transform the matched text part.
To solve your issue:
Put the search pattern in round brackets. This makes the current matched text available for the replacement pattern.
Reference the current match in the replacement pattern using $1 (assuming there's only one pair of round brackets in your search pattern);
Tell LO Writer to use lower-case characters when replacing.
Step by step (the following example will simply replace every upper-case letter by its lower-case counterpart):
Open find/replace (CTRL+H or Menu Edit -> Find/Replace...)
As search pattern, enter ([:upper:])
Make sure that "Regular expressions" is selected in "Other Options";
As replace pattern, enter $1 (this simply uses the complete current match as replacement);
Still with cursor in the "Replace" input box, hit the Format... button; this will open the "Replace with Formatting" window.
In the "Replace with Formatting" window, select "Font effects", and from "Effects" -> "Case", select "lowercase". Hit OK.
Execute the Find/Replace.

Related

Uppercase after every character in NP++

I want to turn every letter after : to uppercase on every single line.
For example from:
nerd:class:ace
make:milk
lake:cake
to
nerd:Class:Ace
make:Milk
lake:Cake
Open Replace menu with Ctrl+h.
Ensure the Regular expression checkbox is ticked.
Enter :([a-z]) in the Find what : field (Alt+f). This matches and captures any letter following a :.
Enter :\U$1 in the Replace with : field (Alt+l). \U uppercases the captured letter in the matched group $1.
Press Alt+a to Replace All.

Replace full stop between letters with hypen in sentance

Somehow some text pages I've been given seem to have a full stop where a hyphen should be.
For example, "Then it happened.first one foot.then the other.". As you can see there is a full-stop where a hyphen should be.
I figured out the Regex to 'find' ([a-z][.][a-z]) all the occurences but can't figure out the 'replace'.
When I tried, [ - ], [-], [a-z][-][a-z], [a-z][ - ][a-z] and [a-z][ ][-][ ][a-z] it removes the last letter of the the precceding word and the first letter of the following one.
I'm using a text editor (TextPad).
How do I solve this?
Consider [.](?=[a-z]):
It does avoid abbreviations assuming they're only uppercase.
It does not handle "Then it happened.Winnie the Pooh looked up." (The word after the hyphen is a proper noun.)
It also does not handle "Then it happened.G.W. Bush looked up." (The word after the hyphen is an abbreviation.)
To handle those cases, consider (?<![A-Z])[.](?!\s|$):
It says that the letter prior to the . should not be uppercase.
It also says that there shouldn't be spaces or end-of-lines after it.
You can perform the replace with just " - ", since the regular expression only consumes the period. (The context is matched using lookarounds.)
See the demo.
I don't have TextPad and cannot test my answer. From what I read, TextPad should support capture groups either via \1 or $1. Try one of the following
Search ([a-z])\.([a-z]) and replace with \1 - \2
or
Search ([a-z])\.([a-z]) and replace with $1 - $2
or
Search \([a-z]\)\.\([a-z]\) and replace with \1 - \2.
or
Search \([a-z]\)\.\([a-z]\) and replace with $1 - $2.
You can try like this
var string = "Then it happened.first one foot.then the other.";
var result = string.replace(/[.]/g,'-');

Regex to match the last character if it is a dot

In OpenOffice Calc how do I remove the last character if it is a dot?
Example:
dog
cat.
rabbit
It becomes:
dog
cat
rabbit
What regex would you use to obtain that?
Regular expression:
To match a ., you have to write \., because . has a special meaning in regular expressions.
To match the end of the line, you have to write $.
Putting it all together, I would use this regular expression: \.$. This will match a dot if it's at the end of the line. Demo
Removing the matched dots:
Open "Find & Replace" window by pressing Ctrl+H
Type regular expression from above into "Search for" field, this is what you want to be replaced
Leave "Replace with" field empty, as you want to replace with nothing, which means it will remove the matched content (the dots)
Under "More/Other options", turn on "Regular expressions"*
Click on "Replace" or "Replace all" button to perform the replacements
Please see documentation of this Calc feature for further details.
In OpenOffice Calc how do I remove the last character if it is a dot?
=IF(RIGHT(A1)=".";LEFT(A1;LEN(A1)-1);A1)

RegEx : Remove line breaks if lookbehind shows a lowercase

I'm doing a CTRL+H (Find & Replace) in Notepad++
I want to find all Line breaks followed by lowercase characters in order to replace them with a space character ; thereby removing unwanted break lines in my text.
Find : \r\n+(?![A-Z]|[0-9])
Replace : insert space character here
*Make sure you selected "Match case" and "Regular expression".
It works perfect.
Now, I'd like to do the same in Microsoft Office Word documents. Any clues?
In Microsoft Word, do the following:
On the Home tab, in the Editing group, click Replace to open the Find and Replace dialog box.
Check the Use wildcards check box. If you don't see the Use wildcards check box, click More, and then select the check box.
In the Find what: box, enter the following regular expression: ([a-z])^13
In the Replace with: box, enter: \1 - thats: (backslash 1 SPACE) (don't forget the space!)
And that's it! Then click either the Replace button or the Replace All button.
Note: In MS Word, the ^13 character matches the paragraph mark at the end of each line.
Here's more information about Microsoft Word and Regular Expressions - http://office.microsoft.com/en-us/word-help/find-and-replace-text-by-using-regular-expressions-advanced-HA102350661.aspx
Edit:
Oh, the above matches lowercase letter PRECEDING line break.
If you want to match line break FOLLOWED by lowercase letter, do the following:
In the Find what: box, enter the following regular expression: ^13([a-z])
In the Replace with: box, enter: \1 - thats: (SPACE backslash 1) (don't forget the space!)
Tested both ways and they both work in Microsoft Word 2010, however documentation says that regular expressions are supported in all versions 97 - 2013.
Good luck! :)
in vscode tap on find press the keys ctrl/enter for second line then type (?=[a-z]) and in the replace add a space

Notepad++ Search and Replace: delete all after "/" in each row

I have a plain text file with content like this:
prežrať/RN
prežrieť/Z
prežrúc/zZ
prežuť/c
...
Q: How can I remove all strings after / symbol in every row in Notepad++?
Desired output:
prežrať
prežrieť
prežrúc
prežuť
...
I am doing this with Find-and-Replace for every different string after /, but there are too many combinations.
Search for: /.*, replace with nothing.
The character / matches just /. ., however, matches any character except newlines, so .* will match a sequence of characters up until the first newline. You can find a demonstration here: http://regex101.com/r/kT0uE3.
If you want to remove characters only after the last on the line /, you should use the regex /[^/]*$. You can find an explanation and demonstration here: https://regex101.com/r/sZ6kP7/74.
In regular expression mode
Find:
/.*
Replace:
(empty)
Set find and replace to regular expression mode.
Find string: /.*
Replace String: (empty string)
Notepad++ find and replace is by default line ended (it won't go over multiple lines)
Using find and replace:
Hit CTRL-H to open the Replace dialogue box
enter /.* into "Find what"
leave "Replace with" empty
Select "Regular expression" (and .matches newline if it is single line)
Click on Replace
Here we go... You are done.