ADD A LINE AT THE END
-
Hello, I am novice to NotePad.
I would need to add a new line of text after certain lines already present (not all of them).
I tried with:
Find what: $
Replace with: \rBut in this way he adds a new line to me at the end of all the lines already present.
How could I do that? Thank you very much!
-
@memytim93
Well you’d have to start by specifying how to identify these “certain lines already present”, i.e., what makes them special? There has to be a pattern to it otherwise it can’t be done.
-
Hello, @memytim19 and All,
Well, it depends on the location where you want to insert this new line :
-
If you want to insert this new line at the very end of current file :
-
SEARCH
\z
-
REPLACE
\r\n
-
-
If you vant to insert this new line after the
Nth
first lines of current file-
SEARCH
(?-s)\A((?:.*\R){
N})
-
REPLACE
\1\r\n
-
-
If you want to insert this new line after the line ( or each line ) containing the named string String
-
SEARCH
(?-s)(?<=
String)(.*\R)
-
REPLACE
\1\r\n
-
For instance, given this INPUT text :
This is a small example of text to test the regexes Hope this test will be OK
The first regex S/R would produce :
This is a small example of text to test the regexes Hope this test will be OK
The regex S/R :
-
SEARCH
(?-s)\A((?:.*\R){5})
-
REPLACE
\1\r\n
gives the following OUTPUT text :
This is a small example of text to test the regexes Hope this test will be OK
and, finally, the regex S/R :
-
SEARCH
(?-s)(?<=test)(.*\R)
-
REPLACE
\1\r\n
would return :
This is a small example of text to test the regexes Hope this test will be OK
Best Regards,
guy038
P.S. :
Of course, select the
Regular expression
search mode and tick theWrap around
option ! -
-
@guy038 Thank you very much, it’s perfect, I still have a lot to learn
-