You are here: PSPad forum > English discussion forum > Find/Replace Regular Expression limit

Find/Replace Regular Expression limit

Goto Page: 1 2 Next

#1 Find/Replace Regular Expression limit

Posted by: garbuya | Date: 2021-01-07 19:33 | IP: IP Logged

PSPad ver 5.04 but in About it still shows 5.03 (bug!!!), Win 10 x64
This is an example

SELECT 1 from dual where 1=1 and 9=9;
SELECT 2 from dual where 2=2 and 8=8;
SELECT 3 from dual where 3=3 and 7=7;
SELECT 4 from dual where 4=4 and 6=6;
SELECT 5 from dual where 5=5 and 5=5;
SELECT 6 from dual where 6=6 and 4=4;
SELECT 7 from dual where 7=7 and 3=3;
SELECT 8 from dual where 8=8 and 2=2;
SELECT 9 from dual where 9=9 and 1=1;

I want to split lines so WHERE will be on next line
So Ctrl+H, checked "Regular Expressions" and "Entire Scope"
Find: (.*)( )(where)(.*)
Replace: $1\n$3$4

As a result only 5 lines are split? Why?
How to bypass this limitation?
Increasing Max Undo to max number 20000 did not help.
If UNDO is a show stopper how to disable UNDO at all?

SELECT 1 from dual
where 1=1 and 9=9;
SELECT 2 from dual
where 2=2 and 8=8;
SELECT 3 from dual
where 3=3 and 7=7;
SELECT 4 from dual
where 4=4 and 6=6;
SELECT 5 from dual
where 5=5 and 5=5;
SELECT 6 from dual where 6=6 and 4=4;
SELECT 7 from dual where 7=7 and 3=3;
SELECT 8 from dual where 8=8 and 2=2;
SELECT 9 from dual where 9=9 and 1=1;

Edited 4 time(s). Last edit at 2021-01-07 19:40 by garbuya.

Options: Reply | Quote | Up ^


#2 Re: Find/Replace Regular Expression limit

Posted by: pspad | Date: 2021-01-07 19:38 | IP: IP Logged

Hello

If PSPad in About shows you 5.0.3, it means you start other PSPad version that you installed.
Check if you don't copy PSpad instead of make shortcut e.t.c.

There is a problem when replace creates new lines. In this case is necessary to start from the end with backward direction.

Options: Reply | Quote | Up ^


#3 Re: Find/Replace Regular Expression limit

Posted by: garbuya | Date: 2021-01-07 19:47 | IP: IP Logged

And this one does not work at all -- I want to split by WHERE and AND
Find: (.*)( )(where|and)(.*)
Replace: $1\n$3$4

Oops!
Still only 5 lines processed, but why WHERE stays on the same line?

SELECT 1 from dual where 1=1
and 9=9;
SELECT 2 from dual where 2=2
and 8=8;
SELECT 3 from dual where 3=3
and 7=7;
SELECT 4 from dual where 4=4
and 6=6;
SELECT 5 from dual where 5=5
and 5=5;
SELECT 6 from dual where 6=6 and 4=4;
SELECT 7 from dual where 7=7 and 3=3;
SELECT 8 from dual where 8=8 and 2=2;
SELECT 9 from dual where 9=9 and 1=1;

Options: Reply | Quote | Up ^


#4 Re: Find/Replace Regular Expression limit

Posted by: garbuya | Date: 2021-01-07 19:50 | IP: IP Logged

I downloaded zip file
PSPad.exe size in zip is 10,811,888 (Jan 1, 2021)
The old PSPad.exe ver 5.03 has size 9,788,032 (Feb 10, 2020)

Options: Reply | Quote | Up ^


#5 Re: Find/Replace Regular Expression limit

Posted by: pspad | Date: 2021-01-07 19:51 | IP: IP Logged

From where you downloaded ZIP file?
When you run directly PSPad.exe from the folder you unpacked ZIP, it shows you 5.0.3 in about dialog?

Options: Reply | Quote | Up ^


#6 Re: Find/Replace Regular Expression limit

Posted by: pspad | Date: 2021-01-07 19:57 | IP: IP Logged

garbuya:
And this one does not work at all -- I want to split by WHERE and AND
Find: (.*)( )(where|and)(.*)
Replace: $1\n$3$4

This is quite nonsense, cause you have "where OR and" in search and want to replace both at once

Edited 1 time(s). Last edit at 2021-01-07 19:57 by pspad.

Options: Reply | Quote | Up ^


#7 Re: Find/Replace Regular Expression limit

Posted by: pspad | Date: 2021-01-07 20:11 | IP: IP Logged

Search: (.*)(where.*)(and.*)
Replace: $1\n$2\n$3

Direction: backward

or you can format output and add tabs before "where" and "and"

Replace: $1\n\t$2\n\t\t$3

Options: Reply | Quote | Up ^


#8 Re: Find/Replace Regular Expression limit

Posted by: garbuya | Date: 2021-01-07 20:48 | IP: IP Logged

Quote:
From where you downloaded ZIP file?
When you run directly PSPad.exe from the folder you unpacked ZIP, it shows you 5.0.3 in about dialog?

Downloaded pspad504en.zip from this site
Help->About shows 5.03(377)

Options: Reply | Quote | Up ^


#9 Re: Find/Replace Regular Expression limit

Posted by: pspad | Date: 2021-01-07 21:00 | IP: IP Logged

garbuya:
Quote:
From where you downloaded ZIP file?
When you run directly PSPad.exe from the folder you unpacked ZIP, it shows you 5.0.3 in about dialog?

Downloaded pspad504en.zip from this site
Help->About shows 5.03(377)

Pspad504en.zip doesn't contains 5.0.3 version.
Run directly pspad.exe from the folder you unpacked zip

Options: Reply | Quote | Up ^


#10 Re: Find/Replace Regular Expression limit

Posted by: garbuya | Date: 2021-01-08 16:36 | IP: IP Logged

Quote:
This is quite nonsense, cause you have "where OR and" in search and want to replace both at once

This is just an example for demonstration.
What I'm trying to say is that PSPad when replaces with Regular Expressions takes only one action going from the right to left and it should process all

a b b c c b b d

Find: (.*)(b|c)(.*)
Replace: $1~$3

a b b c c b ~ d

As you can see only the rightmost occurrence is processed.

regexp_replace takes optional parameters position and occurrence

Quote:
REGEXP_REPLACE( <subject> , <pattern> [ , <replacement> , <position> , <occurrence> , <parameters> ] )

If omitted, by default position = 1 and occurrence = 0 (all occurrences)

It looks like PSPad passing 1 to occurrence instead of 0

Please verify
Thank you

Edited 2 time(s). Last edit at 2021-01-08 16:45 by garbuya.

Options: Reply | Quote | Up ^


Goto Page: 1 2 Next





Editor PSPad - freeware editor, © 2001 - 2021 Jan Fiala, Hosted by Webhosting TOJEONO.CZ, design by WebDesign PAY & SOFT, code Petr Dvořák, Privacy policy and GDPR