end-of-line

jsoup to strip only html tags not new line character?

為{幸葍}努か 提交于 2019-12-01 12:46:26
I have below content in Java where I want to strip only html tags but not new line characters <p>test1 <b>test2</b> test 3 </p> //line 1 <p>test4 </p> //line 2 If I open above content in text rich editor, line 1 and line 2 are displayed in different lines(without showing </p> tag).But in notepad content is shown along with </p> tags. To remove all html tags I used Jsoup.parse(aboveContent).text() It removes all html characters. But it shows all line 1 and line 2 in same line in notepad. Somehow Jsoup also removes newline character. What I tried:- I also tried replacing </p> with \r\n and then

How to configure GNU Emacs to write UNIX or DOS formatted files by default?

巧了我就是萌 提交于 2019-11-30 12:01:39
问题 I've had these functions in my .emacs.el file for years: (defun dos2unix () "Convert a DOS formatted text buffer to UNIX format" (interactive) (set-buffer-file-coding-system 'undecided-unix nil)) (defun unix2dos () "Convert a UNIX formatted text buffer to DOS format" (interactive) (set-buffer-file-coding-system 'undecided-dos nil)) These functions allow me to easily switch between formats, but I'm not sure how to configure Emacs to write in one particular format by default regardless of which

MySQL LOAD DATA INFILE: works, but unpredictable line terminator

眉间皱痕 提交于 2019-11-30 03:55:34
MySQL has a nice CSV import function LOAD DATA INFILE . I have a large dataset that needs to be imported from CSV on a regular basis, so this feature is exactly what I need. I've got a working script that imports my data perfectly. .....except.... I don't know in advance what the end-of-line terminator will be. My SQL code currently looks something like this: LOAD DATA INFILE '{fileName}' INTO TABLE {importTable} FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n' IGNORE 1 LINES ( {fieldList} ); This works great for some import files. However, the import data is coming

Convert all EOL (dos->unix) of all files in a directory and sub-directories recursively without dos2unix

自古美人都是妖i 提交于 2019-11-30 02:22:20
How do I convert all EOL (dos->unix) of all files in a directory and sub-directories recursively without dos2unix ? (I do not have it and cannot install it.) Is there a way to do it using tr -d '\r' and pipes? If so, how? For all files in current directory you can do it with a Perl one-liner: perl -pi -e 's/\r\n/\n/g' * (stolen from here ) EDIT : And with a small modification you can do subdirectory recursion: find | xargs perl -pi -e 's/\r\n/\n/g' You can use sed's -i flag to change the files in-place: find . -type f -exec sed -i 's/\x0d//g' {} \+ If I were you, I would keep the files around

How to configure GNU Emacs to write UNIX or DOS formatted files by default?

喜夏-厌秋 提交于 2019-11-30 01:54:42
I've had these functions in my .emacs.el file for years: (defun dos2unix () "Convert a DOS formatted text buffer to UNIX format" (interactive) (set-buffer-file-coding-system 'undecided-unix nil)) (defun unix2dos () "Convert a UNIX formatted text buffer to DOS format" (interactive) (set-buffer-file-coding-system 'undecided-dos nil)) These functions allow me to easily switch between formats, but I'm not sure how to configure Emacs to write in one particular format by default regardless of which platform I'm using. As it is now, when I run on Windows, Emacs saves in Windows format; when I run in

How to remove ^M

陌路散爱 提交于 2019-11-29 10:01:13
How can I remove the ^M character from a text file (at the end of line) in a Python script? I did the following, and there are ^M at every line-break. file = open(filename, "w") file.write(something) If you're writing the file, you should specify open(filename, "wb") . That way, you'll be writing in binary mode, and Python won't attempt to determine the correct newlines for the system you're on. Python can open a file in binary mode or in text mode. Text is the default, so a mode of "w" means write in text mode. In text mode, Python will adjust the line endings for the platform you're on. This

MySQL LOAD DATA INFILE: works, but unpredictable line terminator

只谈情不闲聊 提交于 2019-11-29 01:04:24
问题 MySQL has a nice CSV import function LOAD DATA INFILE . I have a large dataset that needs to be imported from CSV on a regular basis, so this feature is exactly what I need. I've got a working script that imports my data perfectly. .....except.... I don't know in advance what the end-of-line terminator will be. My SQL code currently looks something like this: LOAD DATA INFILE '{fileName}' INTO TABLE {importTable} FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n'

SourceTree App says uncommitted changes even for newly-cloned repository - what could be wrong?

蓝咒 提交于 2019-11-28 03:48:51
A remote git repository is just cloned to a local box using Atlassian SourceTree . Even no files have really been modified in the work tree, Atlassian lists a bunch of files right away under "Uncommitted changes". Each file shows same line count both as removed and added, and this count equals to the total count of lines in the file. This would somehow give a hint that we're hitting some kind of line ending problem. However, the repository's .gitattribute contains # Set default behaviour, in case users don't have core.autocrlf set. * text=auto that per GitHub article Dealing with Line Endings

How to convert Windows end of line in Unix end of line (CR/LF to LF)

泪湿孤枕 提交于 2019-11-27 06:24:25
I'm a Java developer and I'm using Ubuntu to develop. The project was created in Windows with Eclipse and it's using the CP1252 encoding. To convert to UTF-8 I've used the recode program: find Web -iname \*.java | xargs recode CP1252...UTF-8 this command gives this error: recode: Web/src/br/cits/projeto/geral/presentation/GravacaoMessageHelper.java failed: Ambiguous output in step `CR-LF..data I've serached about it and get the solution here: http://fvue.nl/wiki/Bash_and_Windows#Recode:_Ambiguous_output_in_step_.60data..CR-LF.27 and it says: Convert line endings from CR/LF to a single LF: Edit

Remove end of line characters from Java string

匆匆过客 提交于 2019-11-26 22:04:43
I have string like this "hello java book" I want remove \r and \n from string(hello\r\njava\r\nbook). I want a string as "hellojavabook". How can I do this? Regex with replaceAll. public class Main { public static void main(final String[] argv) { String str; str = "hello\r\njava\r\nbook"; str = str.replaceAll("(\\r|\\n)", ""); System.out.println(str); } } If you only want to remove \r\n when they are pairs (the above code removes either \r or \n) do this instead: str = str.replaceAll("\\r\\n", ""); If you want to avoid the regex, or must target an earlier JVM, String.replace() will do: str=str