You are here: PSPad forum > English discussion forum > Bug in replacing string

Bug in replacing string

#1 Bug in replacing string

Posted by: garbuya | Date: 2024-05-30 16:13 | IP: IP Logged

Hello
I have a string where all fields are delimited by |
a|b|c|||d|||e||||f|
I would like to split it into the separate lines

When I try to do a regexp_replace "|" with "|\n", the application hangs and after ~20 sec I'm getting infinite messages "Access violation error at F55E4C", so I cannot even close app and have to kill it in Task manager

Edited 1 time(s). Last edit at 2024-05-30 16:18 by garbuya.

Options: Reply | Quote | Up ^


#2 Re: Bug in replacing string

Posted by: pspad | Date: 2024-05-31 04:09 | IP: IP Logged

Start on the end of file with backward direction

Options: Reply | Quote | Up ^


#3 Re: Bug in replacing string

Posted by: garbuya | Date: 2024-05-31 14:25 | IP: IP Logged

It does not work
ab|cd||||ef|||ghi|j|
with backward replace "|" by "|\n" returns
|
a|
b|
||
c|
d|
||
||
||
||
e|
f|
||
||
||
g|
h|
i|
||
j|
||

Edited 1 time(s). Last edit at 2024-05-31 14:26 by garbuya.

Options: Reply | Quote | Up ^


#4 Re: Bug in replacing string

Posted by: pspad | Date: 2024-05-31 18:18 | IP: IP Logged

sorry, I didn't noticed, you replace with same char + \n

This is a problem for current editor component used in PSPad.

I can workaround it, but it's anoying.
First replace | with e.g. |§
As second step replace § with \n

Options: Reply | Quote | Up ^


#5 Re: Bug in replacing string

Posted by: garbuya | Date: 2024-05-31 19:11 | IP: IP Logged

Still does not work
ab|cd||||ef|||ghi|j|
ab|$cd|$|$|$|$ef|$|$|$ghi|$j|$
Backward replace $ by \n
Expression replaced one time

Options: Reply | Quote | Up ^


#6 Re: Bug in replacing string

Posted by: vbr | Date: 2024-06-04 11:43 | IP: IP Logged

garbuya:
It does not work
ab|cd||||ef|||ghi|j|
with backward replace "|" by "|\n" returns
[...]

Hi,
i guess, a part of the problem is the search pattern, | is a special (meta)character in regular expression mode;
You have to escape it with a backslash for searching a literal "pipe" |

The other part is indeed the current limitation of PSPad in searching/replacing newlines.
However, in this case the mentioned workaround seems to help - backward search direction, after placing the cursor at the end of the file.

Search for:
\|
Replace with:
|\n

[x] Regular expressions

Search direction
(.) Backward

hth,
vbr

Options: Reply | Quote | Up ^






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