Regex issue

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

Regex issue

Post by Debugger » Fri Oct 19, 2018 12:25 pm

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
Site Admin
Posts: 4193
Joined: Fri Oct 16, 2009 11:31 pm

Re: Regex issue

Post by void » Fri Oct 19, 2018 11:35 pm

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: 204
Joined: Thu Jan 26, 2017 11:56 am

Re: Regex issue

Post by Debugger » Sat Oct 20, 2018 7:28 am

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
Site Admin
Posts: 4193
Joined: Fri Oct 16, 2009 11:31 pm

Re: Regex issue

Post by void » Sat Oct 20, 2018 7:58 am

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: 204
Joined: Thu Jan 26, 2017 11:56 am

Re: Regex issue

Post by Debugger » Sat Oct 20, 2018 10:40 am

\.([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: 916
Joined: Wed May 24, 2017 9:22 pm

Re: Regex issue

Post by NotNull » Mon Oct 22, 2018 3:59 pm

I think you forgot the space (" " or \s). There are no spaces in URL's
Try
\s\.([a-z]+)
?

Debugger
Posts: 204
Joined: Thu Jan 26, 2017 11:56 am

Re: Regex issue

Post by Debugger » Tue Oct 23, 2018 9:25 am

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: 916
Joined: Wed May 24, 2017 9:22 pm

Re: Regex issue

Post by NotNull » Tue Oct 23, 2018 12:24 pm

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: 204
Joined: Thu Jan 26, 2017 11:56 am

Re: Regex issue

Post by Debugger » Tue Oct 23, 2018 3:00 pm

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: 204
Joined: Thu Jan 26, 2017 11:56 am

Re: Regex issue

Post by Debugger » Wed Oct 24, 2018 1:04 pm

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: 916
Joined: Wed May 24, 2017 9:22 pm

Re: Regex issue

Post by NotNull » Wed Oct 24, 2018 3:59 pm

Use \s{1,} instead of \s to match multiple spaces (at least 1)

Debugger
Posts: 204
Joined: Thu Jan 26, 2017 11:56 am

Re: Regex issue

Post by Debugger » Wed Oct 24, 2018 4:09 pm

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