Starting points for your own code. Run them in the environment shown below.
Node.js 22+ · ES module (.mjs)
Current inputs apply only to fields used by the example. Selected files are not embedded.
Install dependencies
const text = "Order 123, Order 456";
const pattern = /\d+/g;
console.log([...text.matchAll(pattern)].map(match => ({
value: match[0], index: match.index,
})));
console.log(text.replace(pattern, "#"));
// Use a worker with a timeout for untrusted patterns.
Put it to work
Use (?<name>\w+)@(?<domain>[\w.]+) to extract two parts of an email address.
Details that matter
Format and meaning
Uses the JavaScript RegExp engine. Other languages may behave differently.
Using it correctly
g enables global matching, i ignores case, and m enables multiline anchors.
Common pitfalls
Reference captured groups with $1 or $<name> in replacement text.
Supported scope and limits
100 KB input, 1.5 second execution limit, at most 1,000 matches
Split inputs that exceed the limit. If a format or algorithm is unsupported, choose a tool that matches your requirements instead of silently changing the format.