Questions tagged [end-of-line]

The end of a physical line

The end of a line is usually signaled by the '\n', '\r' or '\r\n' characters.

The line that has ended is the physical line, as is observed by the line-break in the visual text. This is different from the end of a logical line in programming languages, which is signaled by the ; character in many languages including the family of languages, , etc

134 questions
3
votes
1 answer

Regex not validating end of string

Consider the following scenario (Javascript code): regex = new RegExp((/([\d,.]+)[ $]/)); value = "2.879" The regexp doesn't match value, but it matches (value+" ") therefore i think that the $ is not matched? Why is that? Shouldn't the $…
user3452075
  • 411
  • 1
  • 6
  • 17
3
votes
2 answers

Incomplete final line when trying to read csv in R

I've got R v.2.15.1 running on Mac OS 10.8.2 . Earlier today, R started throwing errors at me every time I try to import ANY recently created (today) csv files. Older (before today) csv files work fine, but anything I create that's new will not read…
user1751735
  • 31
  • 1
  • 2
3
votes
1 answer

C++ string splitting segmentation error

I am splitting a string into a vector of strings vector tokens; stringstream strstm(str); string item; while (getline(strstm, item, ' ')) { tokens.push_back(item); } token_idx = 0; cout << "size = " <<…
Jason Hu
  • 1,237
  • 2
  • 15
  • 29
2
votes
1 answer

VS & VS code customize shortcuts for common actions

I'm wondering if there is a way to customize any shortcut in Visual Studio / VSCode? E.g. I don't like using the "end" button to go to the end of the current line because I don't want to move my right hand to far away from the main A-Z keys.
2
votes
2 answers

How does Perl regexp anchor $ actually handle a trailing newline?

I recently discovered some unexpected behaviour for the end-of-string anchor $ in a Perl Regular Expression (Perl 5.26.1 x86_64 on OpenSuse 15.2). Supposedly, the $ refers to the end of the string, not the end of a line as it does in grep(1). Hence…
MSohnius
  • 23
  • 3
2
votes
3 answers

Preserve line breaks when adding template literal to html with JavaScript

How would I preserve the end-of-line characters in the str template literal below when adding to html? let str = ` Woke up this morning, ate a baguette, smiled at a person and they smiled…
Lee
  • 29,398
  • 28
  • 117
  • 170
2
votes
4 answers

Delete last line break using sed

How to delete the last \n from a file. The file has a last blank line created for a line break in the last text line. I'm using this command: sed '/^\s*$/d' But that las blank line is not removed.
Carlos
  • 131
  • 3
  • 13
2
votes
4 answers

Python: Specify end-of-line format for reading files

I'm writing a Python script which processes a text file. I expect to process files generated from different people, working under different operating systems. Is there a nice way to figure out which OS created the text file, and specify the…
ajwood
  • 18,227
  • 15
  • 61
  • 104
2
votes
1 answer

CodeMirror - Check if cursor is at end of line

I set readonly lines in my editor this way: editor.on('beforeChange', function(cm, change) { if (~readOnlyLines.indexOf(change.from.line)) { change.cancel(); } } Where readOnlyLines is an array containing numbers of the lines to be…
ale93p
  • 464
  • 8
  • 20
2
votes
3 answers

java regex $ metacharacter

I am new to java regex.I saw this in Docs: $ The end of a line But when I try this snippet: String str = "firstline\r\nsecondline"; String regex = "$"; System.out.println(str.replaceAll(regex, "*")); I guess result will…
hasanghaforian
  • 13,858
  • 11
  • 76
  • 167
2
votes
2 answers

End of line character / Carriage return

I'm reading a normal text file and write all the words as numbers to another text. When a line finishes it looks for a "new line character (\n)" and continues from the new line. In Ubuntu it executes perfectly but in Windows (DevC++) it cannot…
mrtgnccn
  • 173
  • 2
  • 2
  • 6
2
votes
3 answers

RegExp: How to find lines that don't end with some pattern?

I have a log-file. Most of the lines in it ends with some sub-string (for example it 0.02). I can filter that lines with pattern 0\.02$. But how I can filter rest lines, other than ending with 0.02?
Loom
  • 9,768
  • 22
  • 60
  • 112
2
votes
2 answers

c# copy text till end of line richtextbox

I have a problem where I need to get specific strings out of a text file. This file is a settings file to something so most of the time what I need is contained in one line. I need to copy these unknow strings into textBoxes, but I know the text…
WolfyD
  • 865
  • 3
  • 14
  • 29
2
votes
1 answer

linux shell - adding full stop (period) to end of lines which do not end with full stop, in a corpus

I have a big corpus which is segmented at the sentence level. That means each line contains one sentence. Some of these lines end with full stop (period) some don't. I am looking for an efficient way to add full stops to the end of the lines which…
MAZDAK
  • 573
  • 1
  • 4
  • 16
2
votes
3 answers

Merge files with different end-of-line character

I work with GIT on Linux, and my colleague works with GIT on Windows. I commited some changes to a file, and my colleague commited some other changes to that file. My colleague pushed, and I pulled. Now, my entire file is a one big conflict: <<<<<<<…
Erel Segal-Halevi
  • 33,955
  • 36
  • 114
  • 183
1 2
3
8 9