gpt-4.1-mini-2025-04-14· OpenAI
WildChat-4.8M (AI2)
regex starting line
- User
regex starting line
- Assistant
If you want a regular expression (regex) that matches the start of a line, you use the caret symbol
^.^matches the position at the start of a line (or the start of the string if multiline mode is off).
Example usage:
-
To match a line that starts with "Hello":
^Hello -
To match the very start of the string only (if multiline mode is off):
^
Multiline mode
If you're working on a multiline string and want
^to match the start of each line, enable multiline mode:- In many languages, this is done with the
mflag. - For example, in JavaScript:
const regex = /^Hello/m;
Summary:
^= start of line/string- With
mflag: start of each line within a multiline string
Let me know if you want a regex for a specific language or context!