Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

To indicate both a lookahead assertion and the end of a line in a regular expression, use the syntax (?=$) where ?= indicates a positive lookahead assertion and $ indicates the end of line anchor.

For example, to match the word "hello" only if it occurs at the end of a line, you can use the following regex:

hello(?=$)

This would match "hello" in "world\nhello" but not in "hello world".