<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../../style.css">
<title>
Gambas Documentation - LIKE
</title>
</head>
<table class="none" width="100%" cellpadding="0" cellspacing="0" border="0">
<tr><td align="left">
<font size="-1">
<a href="../../help+en"><img class="flag" alt="Home" border="0" src="../../img/lang/en.png" align="center"></a>&nbsp;
<a href="../lang+en">Up</a>&nbsp;
<a href="library+en">Previous</a>&nbsp;
<a href="lineinput+en">Next</a>&nbsp;
</td></tr></table>
<div class="notab">
<h1>
LIKE
</h1>
<div class="black"><font size="-2"><b>Syntax</b></font></div>
<pre class="syntax"><u>bResult</u> <b>=</b> <u>sExpression</u> <b>LIKE</b> <u>sPattern</u> AS Boolean</pre><p>

Returns <tt><a href="true+en">TRUE</a></tt> if the <a href="../comp/gb/string+en">String</a> <u>sExpression</u> matches the <a href="../comp/gb/string+en">String</a> <u>sPattern</u>.
<p>
The pattern can contain the following generic characters:
<p>
<table class="table" border="0" bordercolor="#000000" cellpadding="4" cellspacing="0">
<tr><th>
Generic character
</th><th>
Matches
</th></tr>
<tr class="dark"><td valign="top">
<tt>*</tt>
</td><td valign="top">
Any number of any character.
</td></tr>
<tr><td valign="top">
<tt>?</tt>
</td><td valign="top">
Any single character.
</td></tr>
<tr class="dark"><td valign="top">
<tt>[abc]</tt>
</td><td valign="top">
Any character between the brackets.
</td></tr>
<tr><td valign="top">
<tt>[x-y]</tt>
</td><td valign="top">
Any character in the interval.
</td></tr>
<tr class="dark"><td valign="top">
<tt>[^x-y]</tt>
</td><td valign="top">
Any character not in the interval.
</td></tr>
<tr><td valign="top">
<i>space</i>
</td><td valign="top">
Any number of space or character with an <a href="../def/ascii+en">ASCII</a> code lower then 32.
</td></tr>
</table>
<p>
The special generic character <tt>\</tt> prevents its following character to be interpreted as generic.
<p>
<div class="gray"><font size="-2"><b>Example</b></font></div>
<pre class="example">PRINT &quot;Gambas&quot; LIKE &quot;G*&quot;
<hr>True</pre>
<div class="gray"><font size="-2"><b>Example</b></font></div>
<pre class="example">PRINT &quot;Gambas&quot; LIKE &quot;?[Aa]*&quot;
<hr>True</pre>
<div class="gray"><font size="-2"><b>Example</b></font></div>
<pre class="example">PRINT &quot;Gambas&quot; LIKE &quot;G[^Aa]*&quot;
<hr>False</pre>
<p>
<div class="warning"><table class="none" border="0"><tr><td width="40" valign="top"><img border="0" src="../../img/warning.png" align="center"></td><td valign="top">
You must double the backslash character, otherwise <tt>\*</tt> will be interpreted by the compiler as a special character like <tt>\n</tt>, <tt>\t</tt>, ...
<p>
Or you can use this pattern string: <tt>LIKE &quot;G[Aa][*]&quot;</tt>
<p>
<div class="gray"><font size="-2"><b>Example</b></font></div>
<pre class="example">PRINT &quot;Gambas&quot; LIKE &quot;G[Aa]\\*&quot;
<hr>False</pre>
</td></tr></table></div>
<p>
<hr><b>See also</b><br>
<a href="stringop+en">String Operators</a>&nbsp; <a href="../cat/string+en">String Functions</a>&nbsp;

</div>
</body>
</html>

