Regex To Match The First Line Of A Text

A regular expression to match the first line of a file. Can be useful in adding more content to the beginning or end of the first line of your code.

/^(.*)$/m

Matches:

  • Anything in the first line of a text

Non-matches:

  • Anything after the first line of a text

See Also: