Skip to content

Unicode and flags

The rest of the flags

g, y, s, and the state a global pattern carries around with it.

g is the difference between the first answer and every answer. s lets the dot cross a line break. Neither changes what the pattern means, only how much of the input it is asked about.

y is the interesting one: a sticky pattern is anchored to wherever the search starts. It does not go looking. That makes it the right tool for a tokeniser, where each token must begin exactly where the last one ended.

In JavaScript a g or y expression carries a lastIndex between calls, and reusing one across inputs is a standard afternoon of confusion: the second call starts where the first stopped, on a different string.

This app makes that explicit rather than hidden — every match here starts from a position you can see, which is also why the step count for a global search is the sum of every attempt it made.

Matcher

Every claim on the left has a pattern under it. Press one and it runs here, against the same engine that grades a task.