Regex To Match The First Line Of A Text

Category: Strings

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:

Rate This Regex
Sending
User Review
0 (0 votes)

Expression Flags

Flags Description
i Ignore case sensitive.
g Allows global search.
m Allows multiline search.