22 lines
No EOL
4.6 KiB
HTML
22 lines
No EOL
4.6 KiB
HTML
<!doctype html>
|
||
<html lang="en">
|
||
<head>
|
||
<meta charset="utf-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||
<title>Regex — Ludic</title>
|
||
<meta name="description" content="Regular expressions with PCRE/PECL-compatible syntax over a **linear-time** Thompson NFA (a Pike VM), so a bad pattern from a modder can never trigger…">
|
||
<link rel="stylesheet" href="base.css">
|
||
<link rel="stylesheet" href="docs.css">
|
||
</head>
|
||
<body>
|
||
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||
<main class="wrap item">
|
||
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <span class="here">Regex</span></div>
|
||
<div class="item-head"><span class="kind-badge kind-namespace">namespace</span><h1 id="top">Regex</h1></div>
|
||
<p class="ns-blurb">Regular expressions with PCRE/PECL-compatible syntax over a **linear-time** Thompson NFA (a Pike VM), so a bad pattern from a modder can never trigger catastrophic backtracking — matching is <code>O(n·m)</code>, never exponential. Compile a pattern once and reuse it; an invalid pattern is an <a href="regex-compile"><code>error value</code></a>, never a crash. Supported: literals, <code>.</code>, classes <code>[...]</code> with ranges/negation and <code>\d \w \s</code> (and their negations), anchors <code>^ $</code>, alternation <code>|</code>, capturing and <code>(?:…)</code> groups, and the quantifiers <code>* + ?</code> and <code>{n,m}</code> in greedy or lazy form. Backreferences and look-around are out of scope for a linear engine.</p>
|
||
<div class="ns-methods"><a class="ns-method" href="regex-compile.html"><code class="nm-sig">Regex.compile(pattern) -> Regex</code><span class="nm-tip">Compile a pattern once for reuse; returns an error value (null) if it is invalid.</span></a><a class="ns-method" href="regex-valid.html"><code class="nm-sig">Regex.valid(pattern) -> bool</code><span class="nm-tip">True if the pattern is well-formed (compiles without error).</span></a><a class="ns-method" href="regex-matches.html"><code class="nm-sig">Regex.matches(text, pattern) -> bool</code><span class="nm-tip">True if the pattern matches anywhere in the text (a search).</span></a><a class="ns-method" href="regex-test.html"><code class="nm-sig">Regex.test(text, re) -> bool</code><span class="nm-tip">Like matches, but reuses an already-compiled Regex.</span></a><a class="ns-method" href="regex-find.html"><code class="nm-sig">Regex.find(text, pattern) -> Match</code><span class="nm-tip">The first match of the pattern in the text (a Match, or null if none).</span></a><a class="ns-method" href="regex-exec.html"><code class="nm-sig">Regex.exec(text, re) -> Match</code><span class="nm-tip">Like find, but with an already-compiled Regex.</span></a><a class="ns-method" href="regex-next.html"><code class="nm-sig">Regex.next(text, re, from) -> Match</code><span class="nm-tip">The next match at or after byte offset from — the basis of a find-all loop.</span></a><a class="ns-method" href="regex-replace.html"><code class="nm-sig">Regex.replace(text, pattern, replacement) -> string</code><span class="nm-tip">Replace every match; the replacement expands \0..\9 group references.</span></a><a class="ns-method" href="regex-group.html"><code class="nm-sig">Regex.group(match, n) -> string</code><span class="nm-tip">The text of capture group n (group 0 is the whole match); empty if unset.</span></a><a class="ns-method" href="regex-group_count.html"><code class="nm-sig">Regex.group_count(match) -> int</code><span class="nm-tip">How many capture groups the match's pattern has.</span></a><a class="ns-method" href="regex-start.html"><code class="nm-sig">Regex.start(match, n) -> int</code><span class="nm-tip">The start byte offset of group n, or -1 if it did not participate.</span></a><a class="ns-method" href="regex-end.html"><code class="nm-sig">Regex.end(match, n) -> int</code><span class="nm-tip">The end byte offset of group n, or -1 if it did not participate.</span></a><a class="ns-method" href="regex-ok.html"><code class="nm-sig">Regex.ok(match) -> bool</code><span class="nm-tip">True if the match succeeded (the Match is non-null).</span></a></div>
|
||
<a class="back" href="api.html">← All symbols</a>
|
||
</main>
|
||
<script src="ludic-highlight.js"></script>
|
||
<script>Ludic.installCards(); Ludic.flashTarget();</script>
|
||
</body></html> |