Questions tagged [start-of-line]

The beginning of a line

In most systems, the end of a line is signaled by '\n', '\r' or '\r\n'. However, there is no explicit signal for the start of a line. There is a notion of a line starting immediately after the end of line characters; however, this does not account for the first line of a stream which is not preceded by these symbols.

This is especially important when considering regular expressions which can be used to match characters or sequences at the start of a line.

4 questions
7
votes
5 answers

Why is the start of a line "^" and the end of line "$"?

I never remember whether ^ matches the beginning of the line and $ matches the end of it or the other way around. A good mnemonic would be that the $ sign is always before the price, therefore it matches the beginning of a line - unfortunately it's…
laurent
  • 88,262
  • 77
  • 290
  • 428
1
vote
3 answers

parser name defined to default :"parse" warning bison after %start

I have a bison-flex project working on linux ubuntu vmPlayer, and for some reason I have a warning I can't get off.. this is the beginning of my file, and my program (extra.y is bison file) does start with "lines": %{ #include
mooly
  • 113
  • 1
  • 8
1
vote
3 answers

Regular expression to match beginning and end of a line?

Could anyone tell me a regex that matches the beginning or end of a line? e.g. if I used sed 's/[regex]/"/g' filehere the output would be each line in quotes? I tried [\^$] and [\^\n] but neither of them seemed to work. I'm probably missing…
Dom Brown
  • 201
  • 1
  • 2
  • 9
-2
votes
5 answers

Replace substrings with an incremented counter value

Basically what I'm looking for is the PHP version of this thread: Find, replace, and increment at each occurence of string I would like to replace the keyword following > at the start of rach line with an incrementing counter. If my input is: >num,…
Circle B
  • 1,616
  • 3
  • 26
  • 45