What’s going on here? This is truthy because the | has a low precedence. It’s evaluated last, after other characters
like () and ?. To put this Regex into words (I think): “does this string match
anything before the pipe (including the start of line character), or anything
after the pipe (including the end of line character)?”. The
expression matches on ^hello and ignores anything after that.

We can contain it by telling the pipe to stop evaluating. Parentheses work
because they have a higher order of precedence. Here’s our new Regex:

Today I Learned is an open-source project by
Hashrocket
that exists to catalogue the sharing & accumulation of knowledge
as it happens day-to-day. Posts have a 200-word limit, and
posting is open to any Rocketeer as well as selected friends of
Hashrocket. We hope you enjoy learning along with us.