|
| 1 | +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| 2 | +<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US"> |
| 3 | +<head> |
| 4 | +<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> |
| 5 | +<meta http-equiv="X-UA-Compatible" content="IE=11"/> |
| 6 | +<meta name="generator" content="Doxygen 1.14.0"/> |
| 7 | +<meta name="viewport" content="width=device-width, initial-scale=1"/> |
| 8 | +<title>Retro Rocket OS: MATCH Keyword</title> |
| 9 | +<link href="tabs.css" rel="stylesheet" type="text/css"/> |
| 10 | +<script type="text/javascript" src="jquery.js"></script> |
| 11 | +<script type="text/javascript" src="dynsections.js"></script> |
| 12 | +<script type="text/javascript" src="clipboard.js"></script> |
| 13 | +<link href="navtree.css" rel="stylesheet" type="text/css"/> |
| 14 | +<script type="text/javascript" src="navtreedata.js"></script> |
| 15 | +<script type="text/javascript" src="navtree.js"></script> |
| 16 | +<script type="text/javascript" src="cookie.js"></script> |
| 17 | +<link href="search/search.css" rel="stylesheet" type="text/css"/> |
| 18 | +<script type="text/javascript" src="search/searchdata.js"></script> |
| 19 | +<script type="text/javascript" src="search/search.js"></script> |
| 20 | +<link href="doxygen.css" rel="stylesheet" type="text/css" /> |
| 21 | +<link href="doxygen-awesome.css" rel="stylesheet" type="text/css"/> |
| 22 | +<link href="style.css" rel="stylesheet" type="text/css"/> |
| 23 | +</head> |
| 24 | +<body> |
| 25 | +<div id="top"><!-- do not remove this div, it is closed by doxygen! --> |
| 26 | +<div id="titlearea"> |
| 27 | +<table cellspacing="0" cellpadding="0"> |
| 28 | + <tbody> |
| 29 | + <tr id="projectrow"> |
| 30 | + <td id="projectlogo"><img alt="Logo" src="rr.png"/></td> |
| 31 | + <td id="projectalign"> |
| 32 | + <div id="projectname">Retro Rocket OS |
| 33 | + </div> |
| 34 | + <div id="projectbrief">BASIC-Powered Operating System</div> |
| 35 | + </td> |
| 36 | + </tr> |
| 37 | + </tbody> |
| 38 | +</table> |
| 39 | +</div> |
| 40 | +<!-- end header part --> |
| 41 | +<!-- Generated by Doxygen 1.14.0 --> |
| 42 | +<script type="text/javascript"> |
| 43 | +var searchBox = new SearchBox("searchBox", "search/",'.html'); |
| 44 | +</script> |
| 45 | +<script type="text/javascript"> |
| 46 | +$(function() { codefold.init(); }); |
| 47 | +</script> |
| 48 | +<script type="text/javascript" src="menudata.js"></script> |
| 49 | +<script type="text/javascript" src="menu.js"></script> |
| 50 | +<script type="text/javascript"> |
| 51 | +$(function() { |
| 52 | + initMenu('',true,false,'search.php','Search',true); |
| 53 | + $(function() { init_search(); }); |
| 54 | +}); |
| 55 | +</script> |
| 56 | +<div id="main-nav"></div> |
| 57 | +</div><!-- top --> |
| 58 | +<div id="side-nav" class="ui-resizable side-nav-resizable"> |
| 59 | + <div id="nav-tree"> |
| 60 | + <div id="nav-tree-contents"> |
| 61 | + <div id="nav-sync" class="sync"></div> |
| 62 | + </div> |
| 63 | + </div> |
| 64 | + <div id="splitbar" style="-moz-user-select:none;" |
| 65 | + class="ui-resizable-handle"> |
| 66 | + </div> |
| 67 | +</div> |
| 68 | +<script type="text/javascript"> |
| 69 | +$(function(){initNavTree('MATCH.html','',''); }); |
| 70 | +</script> |
| 71 | +<div id="container"> |
| 72 | +<div id="doc-content"> |
| 73 | +<!-- window showing the filter options --> |
| 74 | +<div id="MSearchSelectWindow" |
| 75 | + onmouseover="return searchBox.OnSearchSelectShow()" |
| 76 | + onmouseout="return searchBox.OnSearchSelectHide()" |
| 77 | + onkeydown="return searchBox.OnSearchSelectKey(event)"> |
| 78 | +</div> |
| 79 | + |
| 80 | +<!-- iframe showing the search results (closed by default) --> |
| 81 | +<div id="MSearchResultsWindow"> |
| 82 | +<div id="MSearchResults"> |
| 83 | +<div class="SRPage"> |
| 84 | +<div id="SRIndex"> |
| 85 | +<div id="SRResults"></div> |
| 86 | +<div class="SRStatus" id="Loading">Loading...</div> |
| 87 | +<div class="SRStatus" id="Searching">Searching...</div> |
| 88 | +<div class="SRStatus" id="NoMatches">No Matches</div> |
| 89 | +</div> |
| 90 | +</div> |
| 91 | +</div> |
| 92 | +</div> |
| 93 | + |
| 94 | +<div><div class="header"> |
| 95 | + <div class="headertitle"><div class="title">MATCH Keyword </div></div> |
| 96 | +</div><!--header--> |
| 97 | +<div class="contents"> |
| 98 | +<div class="textblock"><div class="fragment"><div class="line">MATCH result, pattern$, haystack$</div> |
| 99 | +</div><!-- fragment --><p>Evaluates a <b>POSIX ERE</b> (extended regular expression) against a string and stores <b>1</b> for a match or <b>0</b> for no match into <span class="tt">result</span>.</p> |
| 100 | +<ul> |
| 101 | +<li><span class="tt">result</span> must be an <b>integer</b> variable.</li> |
| 102 | +<li><span class="tt">pattern$</span> and <span class="tt">haystack$</span> are <b>strings</b>.</li> |
| 103 | +<li>Matching is <b>ASCII-only</b> (no locale/Unicode).</li> |
| 104 | +<li>No capture groups or sub-matches are returned; this is a <b>yes/no</b> test.</li> |
| 105 | +</ul> |
| 106 | +<p><span class="tt">MATCH</span> runs <b>cooperatively</b>: very large or pathological patterns are executed in slices.</p> |
| 107 | +<dl class="section remark"><dt>Remarks</dt><dd>If the pattern is invalid, an error is raised with a descriptive message from the regex engine. Without an error handler, the program terminates. With an <span class="tt">ON ERROR</span> handler, control passes there.</dd></dl> |
| 108 | +<hr /> |
| 109 | +<h3 class="doxsection"><a class="anchor" id="supported-syntax-posix-ere-subset"></a> |
| 110 | +Supported syntax (POSIX ERE subset)</h3> |
| 111 | +<ul> |
| 112 | +<li>Literals: <span class="tt">ABC</span></li> |
| 113 | +<li>Any char: <span class="tt">.</span></li> |
| 114 | +<li>Quantifiers: <span class="tt">* + ?</span> (greedy)</li> |
| 115 | +<li>Character classes: <span class="tt">[abc]</span>, ranges <span class="tt">[a-z]</span>, negation <span class="tt">[^0-9]</span></li> |
| 116 | +<li>Alternation: <span class="tt">A|B</span></li> |
| 117 | +<li>Anchors: <span class="tt">^</span> (start of string), <span class="tt">$</span> (end of string)</li> |
| 118 | +</ul> |
| 119 | +<h3 class="doxsection"><a class="anchor" id="not-supported"></a> |
| 120 | +Not supported</h3> |
| 121 | +<ul> |
| 122 | +<li>Backreferences <span class="tt">\1</span>, <span class="tt">\2</span>, …</li> |
| 123 | +<li>Inline flags like <span class="tt">(?i)</span> (use explicit classes instead, or upper/lower where appropriate)</li> |
| 124 | +<li>PCRE extensions (<span class="tt">\d</span>, <span class="tt">\w</span>, lookaround, etc.)</li> |
| 125 | +<li>Multiline mode: <span class="tt">^</span> and <span class="tt">$</span> match <b>string</b> boundaries only.</li> |
| 126 | +</ul> |
| 127 | +<hr /> |
| 128 | +<h3 class="doxsection"><a class="anchor" id="examples-140"></a> |
| 129 | +Examples</h3> |
| 130 | +<p><b>Simple literal</b></p> |
| 131 | +<div class="fragment"><div class="line">MATCH R, "HELLO", "HELLO WORLD"</div> |
| 132 | +<div class="line">IF R THEN PRINT "Found"</div> |
| 133 | +</div><!-- fragment --><p><b>Anchors</b></p> |
| 134 | +<div class="fragment"><div class="line">MATCH R, "^START", "START HERE"</div> |
| 135 | +<div class="line">PRINT R ' 1</div> |
| 136 | +<div class="line"> </div> |
| 137 | +<div class="line">MATCH R, "END$", "THE END"</div> |
| 138 | +<div class="line">PRINT R ' 1</div> |
| 139 | +<div class="line"> </div> |
| 140 | +<div class="line">MATCH R, "^A", "BA"</div> |
| 141 | +<div class="line">PRINT R ' 0</div> |
| 142 | +</div><!-- fragment --><p><b>Alternation</b></p> |
| 143 | +<div class="fragment"><div class="line">MATCH R, "CAT|DOG", "HOTDOG"</div> |
| 144 | +<div class="line">PRINT R ' 1</div> |
| 145 | +<div class="line"> </div> |
| 146 | +<div class="line">MATCH R, "RED|GREEN", "BLUE"</div> |
| 147 | +<div class="line">PRINT R ' 0</div> |
| 148 | +</div><!-- fragment --><p><b>Character classes and ranges</b></p> |
| 149 | +<div class="fragment"><div class="line">MATCH R, "[0-9]+", "foo123bar"</div> |
| 150 | +<div class="line">PRINT R ' 1</div> |
| 151 | +<div class="line"> </div> |
| 152 | +<div class="line">MATCH R, "[A-Z][a-z]+", "Title"</div> |
| 153 | +<div class="line">PRINT R ' 1</div> |
| 154 | +<div class="line"> </div> |
| 155 | +<div class="line">MATCH R, "[^x]*z$", "crab ballz"</div> |
| 156 | +<div class="line">PRINT R ' 1</div> |
| 157 | +</div><!-- fragment --><p><b>Wildcard and quantifiers</b></p> |
| 158 | +<div class="fragment"><div class="line">MATCH R, "A.*C", "AXYZC"</div> |
| 159 | +<div class="line">PRINT R ' 1</div> |
| 160 | +<div class="line"> </div> |
| 161 | +<div class="line">MATCH R, "A.+C", "AC"</div> |
| 162 | +<div class="line">PRINT R ' 0</div> |
| 163 | +<div class="line"> </div> |
| 164 | +<div class="line">MATCH R, "B*", "AAAA"</div> |
| 165 | +<div class="line">PRINT R ' 1 ' empty match is allowed</div> |
| 166 | +</div><!-- fragment --><p><b>Handling invalid patterns</b></p> |
| 167 | +<div class="fragment"><div class="line">ON ERROR GOTO BAD</div> |
| 168 | +<div class="line">MATCH R, "(?i)HELLO", "hello" ' invalid: (?i) not supported</div> |
| 169 | +<div class="line">PRINT "this line is not reached"</div> |
| 170 | +<div class="line"> </div> |
| 171 | +<div class="line">BAD:</div> |
| 172 | +<div class="line">PRINT "Regex error!"</div> |
| 173 | +<div class="line">RESUME NEXT</div> |
| 174 | +</div><!-- fragment --><hr /> |
| 175 | +<h3 class="doxsection"><a class="anchor" id="notes-151"></a> |
| 176 | +Notes</h3> |
| 177 | +<ul> |
| 178 | +<li>Matching is <b>case-sensitive</b> by default. To approximate case-insensitive tests, normalise your data (e.g., convert both strings to upper case before matching) or use character classes (e.g., <span class="tt">[Hh][Ee][Ll][Ll][Oo]</span>).</li> |
| 179 | +<li>Because <span class="tt">MATCH</span> is cooperative, very large inputs or patterns may take multiple idle ticks to complete. You do not need to poll—control returns to your program automatically once finished.</li> |
| 180 | +<li><span class="tt">^</span> and <span class="tt">$</span> are <b>string</b> anchors, not line anchors; there is no multiline mode.</li> |
| 181 | +<li>The engine is compiled with <span class="tt">REG_NOSUB</span>; capture offsets are not available to BASIC code. </li> |
| 182 | +</ul> |
| 183 | +</div></div><!-- contents --> |
| 184 | +</div><!-- PageDoc --> |
| 185 | +</div><!-- doc-content --> |
| 186 | +<div id="page-nav" class="page-nav-panel"> |
| 187 | +<div id="page-nav-resize-handle"></div> |
| 188 | +<div id="page-nav-tree"> |
| 189 | +<div id="page-nav-contents"> |
| 190 | +</div><!-- page-nav-contents --> |
| 191 | +</div><!-- page-nav-tree --> |
| 192 | +</div><!-- page-nav --> |
| 193 | +</div><!-- container --> |
| 194 | +<!-- start footer part --> |
| 195 | +<div id="nav-path" class="navpath"><!-- id is needed for treeview function! --> |
| 196 | + <ul> |
| 197 | + <li class="navelem"><a href="index.html">Retro Rocket OS</a></li><li class="navelem"><a href="basic-ref.html">BASIC Language Reference</a></li><li class="navelem"><a href="keywords.html">Keywords</a></li> |
| 198 | + <li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.14.0 </li> |
| 199 | + </ul> |
| 200 | +</div> |
| 201 | +</body> |
| 202 | +</html> |
0 commit comments