Need to replace a line feed character in column 86
-
Fellow Notepad++ Users,
Could you please help me the the following search-and-replace problem I am having?
I need to replace the line feed LF character in column 86 (after MM/YY before *01) on multiple lines, but retain the LF in other columns.
Here is the data I currently have (“before” data):
00001-999 UPH MEDICAL GOWN MATERIAL B 1 YDS 1 2550 4/20 *01 3.90 00002-599 29340 VENTILATED MESH WHITE B 1 YDS 1 11 7/16 *01 12.1 6.00 00002-999 UPH KNIT TRIM FOR GOWNS B 1 YDS 1 4/20 *01 00003-999 04043-060 FABRIC MAXIMA ESD MEDI B 1 YDS 1 2550 4/20 *01 34.4 3.90
Here is how I would like that data to look (“after” data):
00001-999 UPH MEDICAL GOWN MATERIAL B 1 YDS 1 2550 4/20 *01 3.90 00002-599 29340 VENTILATED MESH WHITE B 1 YDS 1 11 7/16 *01 12.1 6.00 00002-999 UPH KNIT TRIM FOR GOWNS B 1 YDS 1 4/20 *01 00003-999 04043-060 FABRIC MAXIMA ESD MEDI B 1 YDS 1 2550 4/20 *01 34.4 3.90
To accomplish this, I have tried using the Begin/End Select in Column Mode
I was able to highlight all LF characters in Notepad++ when I show all symbols but I was not able change the LF character
Unfortunately, this did not produce the output I desired, and I’m not sure why. Could you please help me understand what went wrong and help me find the solution?
Many thanks !!
-
@Mark-Boucher said in Need to replace a line feed character in column 86:
Could you please help me understand what went wrong and help me find the solution?
So it should be relatively easy since you state it’s before the *01 (in every line). I would ask though that you ONLY want a LF to be removed. If this file has come from non-windows source that would correct, however in Windows it’s very likely it’s a LF following a CR (carriage return).
You could try the following (search mode regular expression) using the Replace function.
Find What:\n(?=\*01)
Replace With: empty field, nothing hereNote the
\n
is a LF, but if as I say it needs that and CR removed, replace this with\R
Terry
-
If you want to replace
REGEX
(whereREGEX
is any regular expression) starting in then
^th column of any file, the general regex is(?-s)(?<=^.{n})REGEX
.Note that this is potentially rather slow if
n
is large andREGEX
has a lot of matches, because the lookbehind will check up ton
characters on every match.So in this case, you would search
(?-s)(?<=^.{86})\n
, unless you’re saying that the first column of the line is column 1, in which case it’s(?-s)(?<=^.{85})\n
-
@Mark-Boucher said in Need to replace a line feed character in column 86:
the line feed LF character in column 86 (after MM/YY before *01)
If the pattern is consistent that you have one or two digits, a diagonal, two digits, a line break, and “*01” at the beginning of the next line, then just select Search | Replace… from the menu, enter:
Find what :
(?<=\d/\d\d)\R(?=\*01)
Replace with : a single space
Search Mode: Regular expressionand use the Replace All button.
If that gets other sorts of lines that you didn´t want wrapped, then it can be refined, or you can use the counting characters method @Mark-Olson explained.
@Mark-Boucher said in Need to replace a line feed character in column 86:
To accomplish this, I have tried using the Begin/End Select in Column Mode
Rectangular selections won’t work for this, for a couple of reasons. For one thing, you can’t select or change line endings using rectangular selections. In addition, you’re not just selecting the long lines, you’re also selecting “virtual space” past the end of the short lines.