Finding lines starting with lowercase letter - regex

I have a long text which has some lines are seperated. How can I find the lines starting with lowercase letters?

Make sure both the "regular expressions" and "match case" options are checked and try this:
\r\n[a-z]
This will search for a carrriage return (new line) followed by a lowercase letter.

Try
ctrl + h
Then make sure that regular expression is checked and use
^[a-z]

If you hold ctrl + h and you type ^[a-z], it should work, make sure the matches newline option is selected is selected and the regular expression option.
Notepad++ regex helper

Related

How to replace uppercase letters by their lowercase counterparts?

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.

Find and replace using regular expressions - remove double spaces between letters only

Trying to do this in the Atom editor (1.39.1 x64, uBuntu 18.04), though assume this applies to other text editors using regular expressions.
Say we have this text:
This text has some double-spaces. Lets try to remove them.
But not after a full-stop or if three or more spaces.
Which we would like to change to:
This text has some double-spaces. Lets try to remove them.
But not after a full-stop or if three or more spaces.
Using Find with Regex enabled (.*), all occurrences are correctly found using: [a-zA-Z] [a-zA-Z]. But what goes in the Replace row to enforce the logic:
1st letter, single space, 2nd letter?
You can use this
([a-z])\s{2}([a-z])
and replace by $1 $2
Regex Demo
If your editor supports lookarounds you can use
(?<=[a-z])\s{2}(?=[a-z])
Replace by single space character
Regex demo
Note:- don't forget to use i flag for case insensitivity or just change the character class to [a-zA-Z]

Regex - search for numbers, preceded by a comma or quote, that have no digits before the decimal point

So I've been trying to do a regex in Sublime text on a CSV file to find any number that doesn't have any digits before the decimal point. Basically, I need to find any combinations of ".xx or ,.xx in the document and then add a comma after. I tried attacking it from both the positive end (i.e. any .xx with , or ") and also with a negative lookbehind for .xx that does not have a digit in front of it. Nothing seems to work, but since I'm new to regex I'm sure I have the wrong syntax. Any help would be greatly appreciated.
Right now I have this
(?<!\d)(\.\d{2})
which is definitely not working.
Ctrl-H to open Search and Replace, select Regex Search (the icon with .*):
Search: ([",]\.\d\d)
Replace: \1,
This would not check if there is not already a comma after the number. It just added one.
Tested in Sublime Text 3
Use Ctrl + H to open the Search and Replace, enable Regular Expression Alt + R
Find What: [,"]\.\d{2}\K
Replace With: ,
Here is something that worked:
sed 's/[,"]\.[0-9][0-9]*/&,/'

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

How to replace all words before a particular character in a line in Notepad++

How to replace all the words coming before the character '=' in every line of the code in Notepad++?
It can be done with regular expressions.
Find what: ^[\w\s]+\=(.*)$
Replace with: newword\=\1.
See the screenshot below for more information:
You should enter your desired replacement word instead of "newword" in the regular expression.