Regex issue

Off-topic posts of interest to the "Everything" community.
Post Reply
Debugger
Posts: 630
Joined: Thu Jan 26, 2017 11:56 am

Regex issue

Post by Debugger »

How to find the beginning of a lower case letter that starts with a lowercase letter after the dots and spaces.

example

hey, hey ok. hey
void
Developer
Posts: 16698
Joined: Fri Oct 16, 2009 11:31 pm

Re: Regex issue

Post by void »

Sorry, I don't understand, can you please give a couple examples and highlight what you want to match.

[a-z] will match lowercase Latin letters (make sure you enable match case from the Search menu).
[. ] will match a dot or space.
[. ]* will match any number of dots and/or spaces.
\b will match a word boundary.

To match a word, that is all lowercase letters and skips starting dots or spaces:
\b[. ]*[a-z]*\b
Note: Please make sure match case is enabled from the search menu.
Debugger
Posts: 630
Joined: Thu Jan 26, 2017 11:56 am

Re: Regex issue

Post by Debugger »

Find:

Code: Select all

Aby ułatwić Ci spełnienie tych wymagań, dodaliśmy na Twoim.blogu powiadomienie o wykorzystywaniu przez Google określonych plików cookie Bloggera i Google, w tym plików cookie usług Google Analytics i AdSense, oraz o innych danych zbieranych przez Google

=================
Find:

Code: Select all

Aby ułatwić Ci spełnienie tych wymagań, dodaliśmy na Twoim blogu .powiadomienie o wykorzystywaniu przez Google określonych plików cookie Bloggera i Google, w tym plików cookie usług Google Analytics i AdSense, oraz o innych danych zbieranych przez Google
OR

Code: Select all

Aby ułatwić Ci spełnienie tych wymagań, dodaliśmy na Twoim blogu .Powiadomienie o wykorzystywaniu przez Google określonych plików cookie Bloggera i Google, w tym plików cookie usług Google Analytics i AdSense, oraz o innych danych zbieranych przez Google
Replace with:

Code: Select all

Aby ułatwić Ci spełnienie tych wymagań, dodaliśmy na Twoim blogu. Powiadomienie o wykorzystywaniu przez Google określonych plików cookie Bloggera i Google, w tym plików cookie usług Google Analytics i AdSense, oraz o innych danych zbieranych przez Google
Each text is different. It's not the same, please look at it.
void
Developer
Posts: 16698
Joined: Fri Oct 16, 2009 11:31 pm

Re: Regex issue

Post by void »

Please try searching for:

Code: Select all

 \.([a-z]+)
space = match space
\. match a literal .
() = capture match inside bracket to be recalled later with \1
[a-z] match character a-z
+ match previous element one or more times. In this case match a-z once or more.

Replace with:
\. \1

Note: This won't capitalize the first letter of the word, ie:
blogu .powiadomienie
is replaced with:
blogu. powiadomienie
Debugger
Posts: 630
Joined: Thu Jan 26, 2017 11:56 am

Re: Regex issue

Post by Debugger »

\.([a-z]+)

It works in text sentences, but in a regular expression it must still be "ignore/exclude all urls". because the text file also contains URLs, and this regex unnecessarily matches it.
NotNull
Posts: 5458
Joined: Wed May 24, 2017 9:22 pm

Re: Regex issue

Post by NotNull »

I think you forgot the space (" " or \s). There are no spaces in URL's
Try
\s\.([a-z]+)
?
Debugger
Posts: 630
Joined: Thu Jan 26, 2017 11:56 am

Re: Regex issue

Post by Debugger »

NotNull wrote:I think you forgot the space (" " or \s). There are no spaces in URL's
Try
\s\.([a-z]+)
?
The sentences look correctly written, because they do not find incorrectly inserted dots or commas in sentences.

And another question:
And how do only delete empty spaces at the end of a sentence?


Image
NotNull
Posts: 5458
Joined: Wed May 24, 2017 9:22 pm

Re: Regex issue

Post by NotNull »

Debugger wrote:And how do only delete empty spaces at the end of a sentence?
Try searching for
\s{1,}$
; replace it with nothing (effecively deleting the spaces at the end.
Debugger wrote:And another question:
What was the first question? :?
Debugger
Posts: 630
Joined: Thu Jan 26, 2017 11:56 am

Re: Regex issue

Post by Debugger »

The first question was asked and solved, actually there are no more questions. If I want to ask something again, I will create a new topic. Thanks for all the help.
Debugger
Posts: 630
Joined: Thu Jan 26, 2017 11:56 am

Re: Regex issue

Post by Debugger »

Again, I noticed that the number of spaces between the dot may be different, and therefore it still does not work as expected, similarly with commas!
NotNull
Posts: 5458
Joined: Wed May 24, 2017 9:22 pm

Re: Regex issue

Post by NotNull »

Use \s{1,} instead of \s to match multiple spaces (at least 1)
Debugger
Posts: 630
Joined: Thu Jan 26, 2017 11:56 am

Re: Regex issue

Post by Debugger »

NotNull wrote:Use \s{1,} instead of \s to match multiple spaces (at least 1)
or
\s{2}$

Find:
Wszystko, czego naprawdę pragniesz,na pewno wydarzy
OR
Wszystko, czego naprawdę pragniesz ,na pewno wydarzy

Replace with:
Wszystko, czego naprawdę pragniesz, na pewno wydarzy

I need a regex to correct the placement of the comma in the text

============
AND FIND MORE DOTS:
Wszystko, czego naprawdę pragniesz...na pewno wydarzy

Replace with:
Wszystko, czego naprawdę pragniesz... na pewno wydarzy
Post Reply