@ciao-lang/ts-ciao-interface
Version:
Simple Ciao interface for node.
75 lines (74 loc) • 19.5 kB
HTML
<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><meta name="theme-color" content="#273f79"/><link rel="stylesheet" href="lpdoc.css" type="text/css"/><script type="text/javascript" src="lpdoc.js"></script><title>regexp_code (library) — The Ciao System v1.22</title></head><body><div class="lpdoc-page fixleftbar"><a href="#" id="sidebar-toggle-button" class="lpdoc-navbutton"><span id="sidebar-button-arrow">☰</span></a><div id="sidebar" class="lpdoc-sidebar"><div style="height: 40px; margin-left: auto; margin-right: auto"><img src="ciao-logo_autofig.png" width=auto height=100%></div><div class="lpdoc-nav"><span class="lpdoc-on-right"><a class="lpdoc-navbutton" href="regexp_doc.html">↑</a><a class="lpdoc-navbutton" href="regexp_doc.html">←</a><a class="lpdoc-navbutton" href="text_template.html">→</a><a class="lpdoc-navbutton" href="ciaosearch.html">🔍</a></span><span><a href="ciaofulltoc.html">TOC</a></span></div><hr></hr><ul class="lpdoc-itemize-sectpath"><li><a href="ciao.html">The Ciao System</a> »<br/> </li><li><a href="ExtraLibs.html">PART VIII - Additional libraries</a> »<br/> </li><li><a href="regexp_doc.html">Pattern (regular expression) matching</a> »<br/> </li><li><a href=""><strong>regexp_code (library)</strong></a></li></ul><hr></hr><em>ON THIS PAGE</em><ul><li><a href="#Usage and interface">Usage and interface</a></li><li><a href="#Documentation on exports">Documentation on exports</a></li><li><a href="#Documentation on imports">Documentation on imports</a></li></ul></div><div class="lpdoc-main"><div id=""><h1>regexp_code (library)</h1><a class="lpdoc-idx-anchor" href="ciaosearch.html#regexp_code"></a><div id="Usage and interface"><h2>Usage and interface</h2><div class="lpdoc-cartouche"><ul><li><strong>Library usage:</strong><br/><tt>:- use_module(library(regexp/regexp_code)).</tt><li><strong>Exports:</strong><br/><ul class="lpdoc-itemize-minus"><li><em>Predicates:</em><br/><a class="lpdoc-idx-anchor" id="0" href="regexp_doc.html#match_shell/3"><tt>match_shell/3</tt></a>, <a class="lpdoc-idx-anchor" id="1" href="regexp_doc.html#match_shell/2"><tt>match_shell/2</tt></a>, <a class="lpdoc-idx-anchor" id="2" href="regexp_doc.html#match_posix/2"><tt>match_posix/2</tt></a>, <a class="lpdoc-idx-anchor" id="3" href="regexp_doc.html#match_posix/4"><tt>match_posix/4</tt></a>, <a class="lpdoc-idx-anchor" id="4" href="regexp_doc.html#match_posix_rest/3"><tt>match_posix_rest/3</tt></a>, <a class="lpdoc-idx-anchor" id="5" href="regexp_doc.html#match_posix_matches/3"><tt>match_posix_matches/3</tt></a>, <a class="lpdoc-idx-anchor" id="6" href="regexp_doc.html#match_struct/4"><tt>match_struct/4</tt></a>, <a class="lpdoc-idx-anchor" id="7" href="#match_term/2"><tt>match_term/2</tt></a>, <a class="lpdoc-idx-anchor" id="8" href="regexp_doc.html#replace_first/4"><tt>replace_first/4</tt></a>, <a class="lpdoc-idx-anchor" id="9" href="regexp_doc.html#replace_all/4"><tt>replace_all/4</tt></a>.
<li><em>Regular Types:</em><br/><a class="lpdoc-idx-anchor" id="10" href="#shell_regexp/1"><tt>shell_regexp/1</tt></a>, <a class="lpdoc-idx-anchor" id="11" href="#posix_regexp/1"><tt>posix_regexp/1</tt></a>, <a class="lpdoc-idx-anchor" id="12" href="#struct_regexp/1"><tt>struct_regexp/1</tt></a>.
</ul></ul></div></div><div id="Documentation on exports"><h2>Documentation on exports</h2><div><div class="lpdoc-defname"><span class="lpdoc-predtag">PREDICATE</span><a class="lpdoc-idx-anchor" id="match_shell/3" href="ciaosearch.html#match_shell/3">match_shell/3</a></div><div class="lpdoc-deftext"><p><span class="lpdoc-usage-header">Usage:</span><span class="lpdoc-usage-decl"><tt>match_shell(Exp,IN,Rest)</tt>
</span><p>Matches <span class="lpdoc-var">IN</span> against <span class="lpdoc-var">Exp</span>. <span class="lpdoc-var">Rest</span> is the longest remainder of the string after the match. For example, <tt>match_shell("??*","foo.pl",Tail)</tt> succeeds, instantiating <tt>Tail</tt> to <tt>"o.pl"</tt>.</p><ul class="lpdoc-itemize-minus"><li><em>The following properties should hold at call time:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="13" href="#shell_regexp/1"><tt>regexp_code:shell_regexp/1</tt></a>)</span><span><span class="lpdoc-var">Exp</span> is a shell regular expression to match against.
</span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="14" href="basic_props.html#string/1"><tt>regexp_code:string/1</tt></a>)</span><span><span class="lpdoc-var">IN</span> is a string.
</span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="15" href="basic_props.html#string/1"><tt>regexp_code:string/1</tt></a>)</span><span><span class="lpdoc-var">Rest</span> is a string.
</span>
</ul></div></div><p>
<div><div class="lpdoc-defname"><span class="lpdoc-predtag">PREDICATE</span><a class="lpdoc-idx-anchor" id="match_shell/2" href="ciaosearch.html#match_shell/2">match_shell/2</a></div><div class="lpdoc-deftext"><p><span class="lpdoc-usage-header">Usage:</span><span class="lpdoc-usage-decl"><tt>match_shell(Exp,IN)</tt>
</span><p>Matches completely <span class="lpdoc-var">IN</span> (no tail can remain unmatched) against <span class="lpdoc-var">Exp</span> similarly to <a class="lpdoc-idx-anchor" id="16" href="regexp_doc.html#match_shell/3"><tt>match_shell/3</tt></a>.</p><ul class="lpdoc-itemize-minus"><li><em>The following properties should hold at call time:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="17" href="#shell_regexp/1"><tt>regexp_code:shell_regexp/1</tt></a>)</span><span><span class="lpdoc-var">Exp</span> is a shell regular expression to match against.
</span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="18" href="basic_props.html#string/1"><tt>regexp_code:string/1</tt></a>)</span><span><span class="lpdoc-var">IN</span> is a string.
</span>
</ul></div></div><p>
<div><div class="lpdoc-defname"><span class="lpdoc-predtag">PREDICATE</span><a class="lpdoc-idx-anchor" id="match_posix/2" href="ciaosearch.html#match_posix/2">match_posix/2</a></div><div class="lpdoc-deftext"><p><span class="lpdoc-usage-header">Usage:</span><span class="lpdoc-usage-decl"><tt>match_posix(Exp,IN)</tt>
</span><p>Matches completely <span class="lpdoc-var">IN</span> (no tail can remain unmatched) against <span class="lpdoc-var">Exp</span> similarly to <a class="lpdoc-idx-anchor" id="19" href="ciaosearch.html#match_posix/3"><tt>match_posix/3</tt></a>.</p><ul class="lpdoc-itemize-minus"><li><em>The following properties should hold at call time:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="20" href="#shell_regexp/1"><tt>regexp_code:shell_regexp/1</tt></a>)</span><span><span class="lpdoc-var">Exp</span> is a shell regular expression to match against.
</span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="21" href="basic_props.html#string/1"><tt>regexp_code:string/1</tt></a>)</span><span><span class="lpdoc-var">IN</span> is a string.
</span>
</ul></div></div><p>
<div><div class="lpdoc-defname"><span class="lpdoc-predtag">PREDICATE</span><a class="lpdoc-idx-anchor" id="match_posix/4" href="ciaosearch.html#match_posix/4">match_posix/4</a></div><div class="lpdoc-deftext"><p><span class="lpdoc-usage-header">Usage:</span><span class="lpdoc-usage-decl"><tt>match_posix(Exp,In,Match,Rest)</tt>
</span><p></p><ul class="lpdoc-itemize-minus"><li><em>The following properties should hold at call time:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="22" href="#shell_regexp/1"><tt>regexp_code:shell_regexp/1</tt></a>)</span><span><span class="lpdoc-var">Exp</span> is a shell regular expression to match against.
</span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="23" href="basic_props.html#string/1"><tt>regexp_code:string/1</tt></a>)</span><span><span class="lpdoc-var">In</span> is a string.
</span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="24" href="basic_props.html#list/2"><tt>basic_props:list/2</tt></a>)</span><span><span class="lpdoc-var">Match</span> is a list of <span class="lpdoc-var">string</span>s.
</span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="25" href="basic_props.html#string/1"><tt>regexp_code:string/1</tt></a>)</span><span><span class="lpdoc-var">Rest</span> is a string.
</span>
</ul></div></div><p>
<div><div class="lpdoc-defname"><span class="lpdoc-predtag">PREDICATE</span><a class="lpdoc-idx-anchor" id="match_posix_rest/3" href="ciaosearch.html#match_posix_rest/3">match_posix_rest/3</a></div><div class="lpdoc-deftext"><p><span class="lpdoc-usage-header">Usage:</span><span class="lpdoc-usage-decl"><tt>match_posix_rest(Exp,IN,Rest)</tt>
</span><p>Matches <span class="lpdoc-var">IN</span> against <span class="lpdoc-var">Exp</span>. <span class="lpdoc-var">Tail</span> is the remainder of the string after the match. For example, <tt>match_posix("ab*c","abbbbcdf",Tail)</tt> succeeds, instantiating <tt>Tail</tt> to <tt>"df"</tt>.</p><ul class="lpdoc-itemize-minus"><li><em>The following properties should hold at call time:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="26" href="#posix_regexp/1"><tt>regexp_code:posix_regexp/1</tt></a>)</span><span><span class="lpdoc-var">Exp</span> is a posix regular expression to match against.
</span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="27" href="basic_props.html#string/1"><tt>regexp_code:string/1</tt></a>)</span><span><span class="lpdoc-var">IN</span> is a string.
</span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="28" href="basic_props.html#string/1"><tt>regexp_code:string/1</tt></a>)</span><span><span class="lpdoc-var">Rest</span> is a string.
</span>
</ul></div></div><p>
<div><div class="lpdoc-defname"><span class="lpdoc-predtag">PREDICATE</span><a class="lpdoc-idx-anchor" id="match_posix_matches/3" href="ciaosearch.html#match_posix_matches/3">match_posix_matches/3</a></div><div class="lpdoc-deftext"><p><span class="lpdoc-usage-header">Usage:</span><span class="lpdoc-usage-decl"><tt>match_posix_matches(Exp,IN,Matches)</tt>
</span><p>Matches completely <span class="lpdoc-var">IN</span> against <span class="lpdoc-var">Exp</span>. <span class="lpdoc-var">Exp</span> can contain <em>anchored expressions</em> of the form \(<tt>regexp</tt>\). <span class="lpdoc-var">Matches</span> will contain a list of the <em>anchored expression</em> which were matched on success. Note that since POSIX expressions are being read inside a string, backslashes will have to be doubled. For example,<p><pre class="lpdoc-codeblock">?- match_posix_matches("\(aa|bb\)\(bb|aa\)", "bbaa", M).
M = ["bb","aa"] ? ;
no
?- match_posix_matches("\(aa|bb\)\(bb|aa\)", "aabb", M).
M = ["aa","bb"] ? ;
no
</pre></p><ul class="lpdoc-itemize-minus"><li><em>The following properties should hold at call time:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="29" href="#shell_regexp/1"><tt>regexp_code:shell_regexp/1</tt></a>)</span><span><span class="lpdoc-var">Exp</span> is a shell regular expression to match against.
</span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="30" href="basic_props.html#string/1"><tt>regexp_code:string/1</tt></a>)</span><span><span class="lpdoc-var">IN</span> is a string.
</span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="31" href="basic_props.html#list/2"><tt>basic_props:list/2</tt></a>)</span><span><span class="lpdoc-var">Matches</span> is a list of <span class="lpdoc-var">string</span>s.
</span>
</ul></div></div><p>
<div><div class="lpdoc-defname"><span class="lpdoc-predtag">PREDICATE</span><a class="lpdoc-idx-anchor" id="match_struct/4" href="ciaosearch.html#match_struct/4">match_struct/4</a></div><div class="lpdoc-deftext"><p><span class="lpdoc-usage-header">Usage:</span><span class="lpdoc-usage-decl"><tt>match_struct(Exp,IN,Rest,Tail)</tt>
</span><p>Matches <span class="lpdoc-var">IN</span> against <span class="lpdoc-var">Exp</span>. <span class="lpdoc-var">Tail</span> is the remainder of the list of atoms <span class="lpdoc-var">IN</span> after the match. For example, <tt>match_struct([a,*(b),c],[a,b,b,b,c,d,e],Tail)</tt> succeeds, instantiating <tt>Tail</tt> to <tt>[d,e]</tt>.</p><ul class="lpdoc-itemize-minus"><li><em>Call and exit should be compatible with:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="32" href="#struct_regexp/1"><tt>regexp_code:struct_regexp/1</tt></a>)</span><span><span class="lpdoc-var">Exp</span> is a struct regular expression to match against.
</span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="33" href="basic_props.html#string/1"><tt>regexp_code:string/1</tt></a>)</span><span><span class="lpdoc-var">IN</span> is a string.
</span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="34" href="basic_props.html#string/1"><tt>regexp_code:string/1</tt></a>)</span><span><span class="lpdoc-var">Rest</span> is a string.
</span>
</ul></div></div><p>
<div><div class="lpdoc-defname"><span class="lpdoc-predtag">PREDICATE</span><a class="lpdoc-idx-anchor" id="match_term/2" href="ciaosearch.html#match_term/2">match_term/2</a></div><div class="lpdoc-deftext"><p><span class="lpdoc-usage-header">Usage:</span><span class="lpdoc-usage-decl"><tt>match_term(Term1,Term2)</tt>
</span><p>Tests if two terms <span class="lpdoc-var">Term1</span> and <span class="lpdoc-var">Term2</span> match using shell regular expressions.</p><ul class="lpdoc-itemize-minus"></ul></div></div><p>
<div><div class="lpdoc-defname"><span class="lpdoc-predtag">PREDICATE</span><a class="lpdoc-idx-anchor" id="replace_first/4" href="ciaosearch.html#replace_first/4">replace_first/4</a></div><div class="lpdoc-deftext"><p><span class="lpdoc-usage-header">Usage:</span><span class="lpdoc-usage-decl"><tt>replace_first(IN,Old,New,Resul)</tt>
</span><p>Replace the first occurrence of the <span class="lpdoc-var">Old</span> by <span class="lpdoc-var">New</span> in <span class="lpdoc-var">IN</span> and copy the result in <span class="lpdoc-var">Resul</span>.</p><ul class="lpdoc-itemize-minus"><li><em>The following properties should hold at call time:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="35" href="basic_props.html#string/1"><tt>regexp_code:string/1</tt></a>)</span><span><span class="lpdoc-var">IN</span> is a string.
</span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="36" href="#posix_regexp/1"><tt>regexp_code:posix_regexp/1</tt></a>)</span><span><span class="lpdoc-var">Old</span> is a posix regular expression to match against.
</span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="37" href="basic_props.html#string/1"><tt>regexp_code:string/1</tt></a>)</span><span><span class="lpdoc-var">New</span> is a string.
</span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="38" href="basic_props.html#string/1"><tt>regexp_code:string/1</tt></a>)</span><span><span class="lpdoc-var">Resul</span> is a string.
</span>
</ul></div></div><p>
<div><div class="lpdoc-defname"><span class="lpdoc-predtag">PREDICATE</span><a class="lpdoc-idx-anchor" id="replace_all/4" href="ciaosearch.html#replace_all/4">replace_all/4</a></div><div class="lpdoc-deftext"><p><span class="lpdoc-usage-header">Usage:</span><span class="lpdoc-usage-decl"><tt>replace_all(IN,Old,New,Resul)</tt>
</span><p>Replace all occurrences of the <span class="lpdoc-var">Old</span> by <span class="lpdoc-var">New</span> in <span class="lpdoc-var">IN</span> and copy the result in <span class="lpdoc-var">Resul</span>.</p><ul class="lpdoc-itemize-minus"><li><em>The following properties should hold at call time:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="39" href="basic_props.html#string/1"><tt>regexp_code:string/1</tt></a>)</span><span><span class="lpdoc-var">IN</span> is a string.
</span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="40" href="#posix_regexp/1"><tt>regexp_code:posix_regexp/1</tt></a>)</span><span><span class="lpdoc-var">Old</span> is a posix regular expression to match against.
</span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="41" href="basic_props.html#string/1"><tt>regexp_code:string/1</tt></a>)</span><span><span class="lpdoc-var">New</span> is a string.
</span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="42" href="basic_props.html#string/1"><tt>regexp_code:string/1</tt></a>)</span><span><span class="lpdoc-var">Resul</span> is a string.
</span>
</ul></div></div><p>
<div><div class="lpdoc-defname"><span class="lpdoc-predtag">REGTYPE</span><a class="lpdoc-idx-anchor" id="shell_regexp/1" href="ciaosearch.html#shell_regexp/1">shell_regexp/1</a></div><div class="lpdoc-deftext"><p><span class="lpdoc-usage-header">Usage:</span><span class="lpdoc-usage-decl"><tt>shell_regexp(P)</tt>
</span><p><span class="lpdoc-var">P</span> is a shell regular expression to match against.</p><ul class="lpdoc-itemize-minus"></ul></div></div><p>
<div><div class="lpdoc-defname"><span class="lpdoc-predtag">REGTYPE</span><a class="lpdoc-idx-anchor" id="posix_regexp/1" href="ciaosearch.html#posix_regexp/1">posix_regexp/1</a></div><div class="lpdoc-deftext"><p><span class="lpdoc-usage-header">Usage:</span><span class="lpdoc-usage-decl"><tt>posix_regexp(P)</tt>
</span><p><span class="lpdoc-var">P</span> is a posix regular expression to match against.</p><ul class="lpdoc-itemize-minus"></ul></div></div><p>
<div><div class="lpdoc-defname"><span class="lpdoc-predtag">REGTYPE</span><a class="lpdoc-idx-anchor" id="struct_regexp/1" href="ciaosearch.html#struct_regexp/1">struct_regexp/1</a></div><div class="lpdoc-deftext"><p><span class="lpdoc-usage-header">Usage:</span><span class="lpdoc-usage-decl"><tt>struct_regexp(P)</tt>
</span><p><span class="lpdoc-var">P</span> is a struct regular expression to match against.</p><ul class="lpdoc-itemize-minus"></ul></div></div><p>
</div><div id="Documentation on imports"><h2>Documentation on imports</h2>This module has the following direct dependencies:<ul class="lpdoc-itemize-minus"><li><em>System library modules:</em><br/><a class="lpdoc-idx-anchor" id="43" href="lists.html"><tt>lists</tt></a>.
<li><em>Packages:</em><br/><a class="lpdoc-idx-anchor" id="44" href="ciaosearch.html#prelude"><tt>prelude</tt></a>, <a class="lpdoc-idx-anchor" id="45" href="ciaosearch.html#initial"><tt>initial</tt></a>, <a class="lpdoc-idx-anchor" id="46" href="condcomp_doc.html"><tt>condcomp</tt></a>, <a class="lpdoc-idx-anchor" id="47" href="assertions_doc.html"><tt>assertions</tt></a>, <a class="lpdoc-idx-anchor" id="48" href="ciaosearch.html#assertions/assertions_basic"><tt>assertions/assertions_basic</tt></a>, <a class="lpdoc-idx-anchor" id="49" href="dcg_doc.html"><tt>dcg</tt></a>, <a class="lpdoc-idx-anchor" id="50" href="regtypes_doc.html"><tt>regtypes</tt></a>, <a class="lpdoc-idx-anchor" id="51" href="ciaosearch.html#define_flag"><tt>define_flag</tt></a>.
</ul></div></div><div class="lpdoc-footer">Generated with LPdoc using Ciao</div></div><div class="lpdoc-clearer"></div></div></body></html>