Regular Expression - Line (Beginning and End)

About

Page about the definition of line boundary (EOL) in regular expression

Pattern

Boundary Matcher

You can define the begining or the end of a line with boundary matcher

boundary matcher Description
^ The beginning of a line
$ The end of a line

Characters

The end of line pattern are shorthand that defines the end of line whitespace character

  • Linux, Mac: \n - linefeed
  • Windows: \r\n - carriage return + linefeed

The boundary matcher should be used but for the sake of the example, the below pattern will match an end of line on any system (windows, linux, …)

\r??\n

where:

  • \r defines the carriage return character
  • ?? is a lazy quantifier that will match once or not at all
  • \n defines the linefeed character itself and is mandatory on all platform

Powered by ComboStrap