You are here: PSPad forum > English discussion forum > Re: Find & Add (add new line AFTER)

Re: Find & Add (add new line AFTER)

#1 Find & Add (add new line AFTER)

Posted by: Tempy111 | Date: 2022-06-08 12:12 | IP: IP Logged

Hi.. this is probebly gonna be a bit.. of a no-go but..

Doing some basic scripting and there can be such a need when doing some converting and stuff to add tons of new lines ON certain condictions.. .. I'll just go with an example:

If line has "G0" in it, then need to add a new line BELOW that line which has a new command. Problem is, G0 would be at the start of a line with variable stuff after it so a simple find and replace won't work.. it's also often the case of hundreds of such lines which all need the new bit.. and each one will probebly have bits of the top different but all have the G0 in common.

Is it possible to do like a wildcard find and replace which IF "G0 *(random)" then add "LineBreak new line here" without replacing the found G0 line?

sorry if this doesn't make too much sense..

Options: Reply | Quote | Up ^


#2 Re: Find & Add (add new line AFTER)

Posted by: pspad | Date: 2022-06-08 13:08 | IP: IP Logged

This is possible using regular expressions with search/replace

Stay on the bottom of file

Search: (^.*G0.*$)
Replace: $1\n
[x] Regular expressions

(o)backward direction

Options: Reply | Quote | Up ^






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