add characters
-
Hello,
I have a file of 160 000 lines with some empty lines.
I would like to add characters at the beginning of each line, but not when they are empty. I found how to add characters at the beginning or end of the line, but I don’t know the regular expression syntax to go further.
Could someone help me please?Thank you in advance.
-
Hello, @mr-schnok and All,
Not difficult !
SEARCH
(?x) ^ (?! \R )OR^(?!\R)REPLACE
Your text to insert at BEGINNING of NON-EMPTY lines
The search regex means :
Change any beginning of line (
^) with the text to replace, but ONLY IF not immediately followed with aline-breakcharacter, as\Rrepresents, either\r\nor\ror\nBest Regards
guy038
-
Hi, @mr-schnok and All,
Oh… I did not notice that you spoke about adding characters at the end of non-empty lines as well !
In this case, the regex S/R becomes :
SEARCH
(?x-s) (?<= . ) $OR(?-s)(?<=.)$REPLACE
Your text to insert at END of NON-EMPTY lines
The search regex means :
Change any end of line (
$) with the text to insert, but ONLY IF immediately preceded with a standard character (.)BR
guy038
-
Hello @guy038
Thank you very much. It works very well.
And especially thank you for the explanation.Have a nice day.
Phil