Some simple regex questions.
-
- How can I add a comma only to the ends of lines with text?
- How do I combine lines?
- Replace letters of a word, e.g. ‘er’ with ‘s’?
-
- FW:
(?-s).+
RW:$0,
- FW:
\R
RW: make sure it is empty - You mean like at the end of a word?? Maybe… FW:
er\b
RW:s
But really, don’t use this forum as a basic regex learning place (much better places for that)
- FW:
-
if you have a text like:
line 1 line 2 line 3 line 4 line 5
How can I add a comma only to the ends of lines with text?:
find what: ^(.*?)$
replace with: $1,
search mode: regular expression
result:
line 1, line 2, line 3, line 4, line 5,
How do I combine lines?:
find what: \r?\n|\r
replace with:
(one single space)
search mode: regular expression
result:
line 1, line 2, line 3, line 4, line 5,
Replace letters of a word, e.g. ‘in’ with ‘s’?:
find what: in
replace with: s
search mode: regular expression or normal
result:
lse 1, lse 2, lse 3, lse 4, lse 5,
-
concerning the question 1
How can I add a comma only to the ends of lines with text?a regex like
(?-s)\w+.*$
might suit better, doesn’t it?
and replace with$0,
Cheers
Claudia -
OH MY ! … I’m not getting into what with text means if the OP can’t be specific. Notepad++ is a text editor…it’s ALL TEXT!!
[Okay, I’ll get into it…because someone will call me out on it and say that a line-ending is also text…sigh…I took lines with text to mean non-empty lines.]
:-D
-
as you probably already found out, today I’m in guess mode :-D,
so, who knows, at the end it might be that OP was exactly asking
what you and @Meta-Chuh proposed a solution for.Cheers
Claudia -
Curious as to how @Meta-Chuh interpreted the OP’s need, because the suggestion of
^(.*?)$
matches empty lines as well as non-empty… -
you are right (empty lines).
today we just both hit submit at about the same time, otherwise i’d seen your answer and not have given an extra solution if an existing post does the requested job and no further request is given by the OP.