Replace a line with 2 new lines
-
Hello, here is my example:
I have this code
…
N111 M101
N112 G138 G40 G0X86.462Y606.806 M57
N113 G90
N114 ;(Laser Start)
N115 M50
N116 M9
N117 M113
N118 M50
…
I would like to replace the full line of M9 with:
/N138 M9 M37
LAT/OutFlowBurnWhat I did was find M9
Replace with: /N138 M9 M37\nLAT OutFlowBurnbut this leaves the characters before M9 ie N116 in the line. I wanted to replace everything in that line.
It looks like this
N111 M101
N112 G138 G40 G0X86.462Y606.806 M57
N113 G90
N114 ;(Laser Start)
N115 M50
N116 /N138 M9 M37
LAT OutFlowBurn
N117 M113
N118 M50
But I want the N116 gone.
to look like thisN111 M101
N112 G138 G40 G0X86.462Y606.806 M57
N113 G90
N114 ;(Laser Start)
N115 M50
/N138 M9 M37
LAT OutFlowBurn
N117 M113
N118 M50I know is simple but so far I cant figure it out.
-
@Edgar-Rousselin said in Replace a line with 2 new lines:
Replace with:
/N138 M9 M37\nLAT OutFlowBurn
but this leaves the characters before M9 ie N116 in the line. I wanted to replace everything in that line.As an added bonus, you probably also corrupted your file.
Unless your line-ending type was Unix, then you’re OK.
For Windows files, you’d want to use\r\n
rather than\n
in your replace expression.Try:
Find:
(?-s)^.*M9.*
Replace:/N138 M9 M37\r\nLAT OutFlowBurn
Search mode: Regular expressionAgain, for a Windows file; but if you truly have a Unix file type, leave
\n
without\r
in the replace. -
@Alan-Kilborn Thank you!
Will I be able to isolate M9 only in the search. There are instances that I have M95 and it will check it too.To be more specific. this line will always be:
N### M9
Will it possible to narrow that down?
Thank you again
-
Try:
Find:
^N\d{3} M9$
You can learn some of this (regular expression) stuff yourself.
See the USER MANUAL section.
Also see the FAQ entry.