Regex issue

General discussion related to "Everything".
Post Reply
Debugger
Posts: 630
Joined: Thu Jan 26, 2017 11:56 am

Regex issue

Post by Debugger »

How to find all characters = except for three characters =
My regex is incorrect:

^={3}
therube
Posts: 4985
Joined: Thu Sep 03, 2009 6:48 pm

Re: Regex issue

Post by therube »

[^===]
eh, that's probably not right...
^[^===]
& thinking that isn't quite it either!
therube
Posts: 4985
Joined: Thu Sep 03, 2009 6:48 pm

Re: Regex issue

Post by therube »

Disregarding RegEx:

!"===" =

Find files with = in the filename, but not with 3 ===, so 1 or 2 or >3.
Debugger
Posts: 630
Joined: Thu Jan 26, 2017 11:56 am

Re: Regex issue

Post by Debugger »

[^===]
^[^===]
!"===" =

All Regex does not work because nothing is found.

-----
Can not find
-----
Example:
===
=====
=
=====================================

should only find 3 characters ===

Test: Perl Search Engine Emeditor 18.0.9
void
Developer
Posts: 16764
Joined: Fri Oct 16, 2009 11:31 pm

Re: Regex issue

Post by void »

Please try searching for:
^(?!.*===).*$

or, to find atleast one =, but not 3 sequential =
^(?!.*===).*=.*$

or, to find atleast one =, but not 3 sequential =, or 4 or more sequential =
(^(?!.*===).*=.*$)|====+
tuska
Posts: 1052
Joined: Thu Jul 13, 2017 9:14 am

Re: Regex issue

Post by tuska »

Debugger wrote: Example:
===
=====
=
=====================================

should only find 3 characters ===

Code: Select all

^={3}$
?
If it fits, it was a lucky strike today :D

Does not find:
===== ===
Debugger
Posts: 630
Joined: Thu Jan 26, 2017 11:56 am

Re: Regex issue

Post by Debugger »

void tuska

The first regex ignores =
The second Regex finds only one character
I want to find at least one character to change into 3 characters.
But the regex can not include the character = in any http link!

Ignore =
http://bla bla/lbla bla=22041

Include =

Ignore
==
====
and more...
NotNull
Posts: 5461
Joined: Wed May 24, 2017 9:22 pm

Re: Regex issue

Post by NotNull »

= !regex:^[^=]*===[^=]*$


And if this is not for Everything, this thread should definitely be moved to the Off-topic discussion, as similar threads by @Debugger have already caused a lot of confusion that way
Debugger
Posts: 630
Joined: Thu Jan 26, 2017 11:56 am

Re: Regex issue

Post by Debugger »

NotNull -
Regex only works with 3 characters =
How to change a different number of characters (except for 3 characters
and except individual characters in an HTTP link)???


= replace with ===
== replace with ===
===
http://bla bla/lbla bla=22041 (NOT replace)
= OR == OR ==== OR more character "=" always replace with ===
NotNull
Posts: 5461
Joined: Wed May 24, 2017 9:22 pm

Re: Regex issue

Post by NotNull »

I don't understand what you are saying/asking.

If you enter
= !regex:^[^=]*===[^=]*$
on the Everything search bar, you get all files with at least one "=", but not the ones with exactly 3 "=" in a row (4 or more in row will be found).
Debugger
Posts: 630
Joined: Thu Jan 26, 2017 11:56 am

Re: Regex issue

Post by Debugger »

NotNull -
^[^=]*===[^=]*$
OR

^={3}$
OR
([^=]|^)(===)([^=]|$)


We are not talking about the Everything program about the change in the word editor.
Of course, it will not work in any text editor when I want to replace something in a text file.


Each character = (except for 3 characters === and one character in http) should be replaced with 3 characters ===


I have links in the text file that do not contain or contain at least one character or more in the address "="
Here he does not want to change anything.
But in the text file the links are separated in a line with a different combination of = character, and I want to replace all of them with 3 characters =
NotNull
Posts: 5461
Joined: Wed May 24, 2017 9:22 pm

Re: Regex issue

Post by NotNull »

Tried it in Libre Office Writer.
Did a Search/Replace on the second part:
2018-09-18 17_35_01-Untitled 1 - LibreOffice Writer.png
2018-09-18 17_35_01-Untitled 1 - LibreOffice Writer.png (17.28 KiB) Viewed 10624 times
Debugger
Posts: 630
Joined: Thu Jan 26, 2017 11:56 am

Re: Regex issue

Post by Debugger »

NotNull


It works, but the regular expression must be changed because every character starts from the beginning of the line. There must be an exception for HTTP links in which the = CHARACTER also appears

Ignore replacing characters in any url link in which the character is =


Line1:http://www.com.pl/11= (VARIOUS TYPE URL)
Line2:====

Find:^=*$
Replace with:===
NotNull
Posts: 5461
Joined: Wed May 24, 2017 9:22 pm

Re: Regex issue

Post by NotNull »

Do the lines where the ='s should be replaced all start with "===" (no more and no less than 3 ='s)?
Do all the URL-lines start with http?

Some real world examples would help.
Debugger
Posts: 630
Joined: Thu Jan 26, 2017 11:56 am

Re: Regex issue

Post by Debugger »

1. Beginning lines with character = starting from 1 to unknown
2. Beginning lines from the url begin with http or https
NotNull
Posts: 5461
Joined: Wed May 24, 2017 9:22 pm

Re: Regex issue

Post by NotNull »

Then it is simple:

search for:
^=*

replace with:
===
Debugger
Posts: 630
Joined: Thu Jan 26, 2017 11:56 am

Re: Regex issue

Post by Debugger »

NotNull wrote:Then it is simple:

search for:
^=*

replace with:
===
Missing End of Line:$
Your regex is incorrect :lol: because it adds in a line ===http................
My off course is completely correct!

Regular Expression Engine: Onigmo, Perl, Boost.Regex
NotNull
Posts: 5461
Joined: Wed May 24, 2017 9:22 pm

Re: Regex issue

Post by NotNull »

Did you miss the ^ in the search string?
the ^ anchors at the beginning of the line, followed by any number of ='s
In no regex language that I'm aware of this is defined differently.

Ergo: It will *only* replace anything in lines that start with an =
2018-09-18 20_27_31-Untitled 1.odt - LibreOffice Writer.png
2018-09-18 20_27_31-Untitled 1.odt - LibreOffice Writer.png (33.63 KiB) Viewed 10601 times
Debugger
Posts: 630
Joined: Thu Jan 26, 2017 11:56 am

Re: Regex issue

Post by Debugger »

I do not use LibreOffice, only Emeditor. Without a $ character, it replace incorrectly in the case of a URL. That's why he is required in this case.
Post Reply