Code
Work on the text itself: regular expressions, two texts compared, words found by pattern or sound, word breaks put back, and words disguised by a language game’s rule.
Regex Lab
Tests a JavaScript regular expression against text as it is typed: matches are marked and listed with their groups, under the flags g, i, m, s and u, with a replace mode and 12 patterns for texts that hide something. Syntax is that of ECMA-262. Stephen Kleene described regular events in a 1951 RAND memorandum; Ken Thompson's 1968 paper in Communications of the ACM compiled them for text search.
History, how it works, how it was checked, limits
History
Stephen Kleene described regular events in a RAND memorandum of 1951, “Representation of Events in Nerve Nets and Finite Automata”, and Ken Thompson’s “Regular Expression Search Algorithm” in Communications of the ACM (1968) compiled regular expressions for text search. The syntax here is JavaScript’s, as ECMA-262, the ECMAScript Language Specification, defines it.
How it works
A pattern is typed between slashes, with the flags g, i, m, s and u as toggles, g on at first, all saved with sessions and share links; the browser’s RegExp compiles it, and its error message is shown when it will not. The test text is shown with each match marked, alternately shaded, and the matches are listed with their positions and their numbered and named groups, under counts of matches, distinct matches, characters covered and their share of the text; at most 500 are collected. Replace runs the browser’s replace with the replacement string ($1, $2 for groups). Twelve patterns for texts that hide something fill the field on a press, with the flags they need: groups of five letters, a repeated run of three, doubled letters, hex and Base64 runs, binary bytes, number groups, coordinates, a flag, capitals, first letters, invisible characters. Everything updates 150 ms after typing stops, in a worker of its own that stops an expression still running after two seconds and says so.
How it was checked
The matching is the browser’s own regular-expression engine, which the tool does not reimplement, so its correctness is the engine’s. The tests run the tool’s own functions: a pattern that will not build gives the engine’s reason, an empty match moves on a place, the 500-match limit holds, and each of the twelve patterns builds and finds what it names in a sample. The five flags are checked to be saved as toggles. The worker’s matches and replacement are tested, and an expression stopped at the limit. The highlighting has no tests.
The tests hold 21 checks of this tool. None names outside material: they are properties the code is held to. Every tool’s checks
Limits
A pattern that backtracks catastrophically, (a+)+ against a’s that end in another letter, is stopped after two seconds with no answer. Without g only the first match is found and replaced. Positions count UTF-16 code units, so a character beyond U+FFFF counts as two. The y, d and v flags are not offered. The patterns are shapes, not proofs: a run of sixteen letters and digits is marked as Base64 whether it is or not.