Adding linebreaks below characters
-
I need to add a linebreak below a line that contains “--------------” hyphens. And I need to know how to make a whole line bold if it contains a specific word or is below the hyphen and linebreak
-
@kracovwolf
Is a correct restatement of your first need the following: Replace
“hyphens + one newline”
with
“hyphens + two newlines”
?If so, play with Find&Replace function in Extended mode. You will need to worry about finding and replacing each newline as the pair \r\n (ie, CR,LF as made visible when you turn on
View -> Show Symbol -> Show End of Line
. If you screw this up, other software that processes the file may misbehave.As for your second need, npp, as a text editor does not embolden text (even though it allows bolded fonts for styling). Do you mean something like wrapping text with html tags?
-
@neil-schipper Yes sorry I forgot that I was multitasking with a html editor, so yes to the tags.
For the hyphens, I just need to make
this: text ---------- Specific word into: text ---------- Specific word
-
@kracovwolf OK, I think you have enough to go on now for your first need, no?
For your second need, it will be using a regex, something along the lines of finding
.*?Phrase of interest.*?
and replacing with<bold>(1)</bold>
. (These are guidelines, not a tested solution. Try to have some fun with it.) -
@kracovwolf said in Adding linebreaks below characters:
or is below the hyphen and linebreak
Let us know if you solve your first two needs, then someone will help you with the third…
ok, roughly it will be finding something like
(\-\R\R)(.*)
and replacing with(1)<bold>(2)</bold>
(and keep. matches newline
not checked). -
@neil-schipper oops:
\1<bold>\2</bold>
(tested) -
@neil-schipper said in Adding linebreaks below characters:
.?Phrase of interest.? and replacing with <bold>(1)</bold>.
That’s also wrong.
(.*?Phrase of interest.*?$)
<bold>\1</bold>
(tested) -
Hello, @kracovwolf, @neil-schipper and All,
@kracovwolf, as your number of dashes is not the same between your first post and your raw text, in reverse video, here is my regex solution :
-
SEARCH
^-{5,}(\R)
-
REPLACE
$0\1
which adds an empty line, right after any line of, at least,
5
dashes, beginning a line
Regarding your second problem and assuming your statement :
And I need to know how to make a whole line bold if it contains a specific word or is below the hyphen and linebreak
Here is a regex alternative to the @neil-schipper solution :
-
SEARCH
(?-s).*Place of interest.*|-{5,}\R\R\K.+
-
REPLACE
<bold>$0</bold>
Notes :
-
For these two regex S/R , select the
Regular expression
search mode and tick theWrap around
option -
For the last regex S/R, you must use the
Replace All
button ( Do not use theReplace
button ! )
Best Regards,
guy038
-
-
I’m not sure if it works well. It does add a linebreak, but I forgot that I’m supposed to type words after the linebreak. And the whole line (title) is supposed to have the bold tag.
like
------ **Title** text here
-
Hi, @kracovwolf and All,
Ah… yes, regular expressions are the school of precision !
So, you mean that you have this kind of INPUT text :
----- Title here Text here ... ...
and that you expect the OUTPUT text below :
----- **Title here** Text here ... ...
Right ? If so, use the following regex S/R :
SEARCH
(?-s)^-{5,}(\R)(.+)
REPLACE
-----\1\1**\2**
Best Regards,
guy038
-
@guy038 didn’t seem to work
-
Hi, @kracovwolf and All,
Well, You didn’t say that an empty line was already present between the
----
line and the line which must be changed as bold !So, here is the final solution which works in the two cases !
With the INPUT text, below :
FIRST case : ----- Title_1 Text here ... ... SECOND case : ----- Title_2 Other Text here ... ...
And using the regex S/R :
-
SEARCH
(?-s)^-{5,}(\R)\R?(.+)
-
REPLACE
-----\1\1**\2**
You should get the expected text :
FIRST case : ----- **Title_1** Text here ... ... SECOND case : ----- **Title_2** Other Text here ... ...
Cheers,
guy038
-
-
@guy038 I was wondering why you were using the asterisk, since its not the html tag for bold. so i should swap out the asterisks for <b> or style="font-weight: bold;?
-
@kracovwolf said in Adding linebreaks below characters:
so i should swap out the asterisks for <b> or style="font-weight: bold;?
You should do that…if that is what you want to obtain.
I think you can do a BIT of your own thinking here.