I have a CSV file that needs to be cleaned. This is a one-time thing, so I would like to do it in Notepad ++, if possible.
The CSV file has two fields, one of which is enclosed in quotation marks. I would like to remove any carriage returns from the field specified in the field. I tried to use this template, but I can not understand it correctly ...
(.*)\"(.*)\n(.*)\"(.*)
Also correct me if I am wrong, but I believe the value of "replace with" would be as follows:
\1\2\3\4
Thanks in advance.
I am also open to alternative solutions, such as a quick and dirty PERL script.
StackOverflow , , . PERL. ! , , , .
, , . !
$string123 =~ s/((?:^[^"]*"|(?!^))[^"]*?(?:"[^"]*"[^"]*?)*?)(\n{1,})/$1/g;
, , -, , , , , Perl.
, . , Perl , \n, , /x 0D.
, :
$string123 = ~ s/((?: ^ [^ "]" | (?! ^)) [^ "]? (?:" [^ "]" [^ "]?)?) (\n {1,})/$1/g;
:
$string123 = ~ s/((?: ^ [^ "]" | (?! ^)) [^ "]? (?:" [^ "]" [^ "]?)?) (\x0D {1,})/$1/g;
, !
- ++, :
/show invisible characters CR LF.
, csv ( , ) LF. CR IN IT. , , , , , CR/LF ( , CR LF)!
, . CRLF, f & r, "find what:" CRLF. .
TADA! , .
Notepad ++. Shreyas , , \r\n . :
[^"]"(([^"]*)\r\n([^"]*))+"
, , , :
[somethin0]"[somethin1]NEWLINE[somethin2]"
somethin1 somethin2 are\2 \3 (\1 - ), somethin0 - ( , ). , , :
[somethin0]"\2 \3"
! , . Single replace . replaceAll ( " " - , )
replaceAll
Notepad ++ , \n \t. , - .
Eclipse, .
,
\n , # .
, \n
π, . char. Ctr + H
Hope this works for you.
Well ... my RegEx is terrible and I can't answer your question. However, here is a small JS function that you can use that should be able to do what you want.
function removeNewLines(str){ var quotedStrings = str.split(/["'](.*)?["']/g), i = 0; for( ; i < quotedStrings.length; i++){ str = str.replace(quotedStrings[i], quotedStrings[i].replace(/[\r\n]/g,"")); } return str; } removeNewLines("\"asdf\r\nas\"asdf\'as\nd\'asdf\"asdf\r\nasf\r\n\"") === "\"asdfas\"asdf'asd'asdf\"asdfasf\"";
Here is an answer specifically for Notepad ++
Menu: TextFX > TextFX Edit > DeleteEmpty Lines
TextFX > TextFX Edit > Delete
This menu item has the option Delete extra lines.
Source: https://habr.com/ru/post/1711112/More articles:How can I verify that a Perl program compiles from my test suite? - perlDelphi - How to manage Z Order of TopDialog - delphiLooking for a simple scripting language that can easily integrate with .NET. - scriptingJava Performance Inconsistency - javaКак узнать, когда процесс генерации индекса Lucene завершен - luceneWhat is the SQL WHERE equivalence in lambda expressions? - c #How does _XPG4_2 and others that work on Solaris work? - cDo all form validation errors appear at the top in symfony? - phpCan I ignore the WaitHandle.SignalAndWait call to profile performance? - performanceHow to get Eclipse to run all my Groovy test tests? - eclipseAll Articles