| 1 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" |
| 2 |
"http://www.w3.org/TR/html4/strict.dtd"> |
| 3 |
<html> |
| 4 |
<head> |
| 5 |
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> |
| 6 |
<title>strmatch</title> |
| 7 |
<meta http-equiv="Content-Style-Type" content="text/css"> |
| 8 |
<link rel="stylesheet" href="../../style.css" type="text/css"> |
| 9 |
</head> |
| 10 |
|
| 11 |
<body> |
| 12 |
|
| 13 |
|
| 14 |
<h1>strmatch</h1> |
| 15 |
|
| 16 |
<p> |
| 17 |
Matches the target string with the regular expression. <em>(version 4.59 or later)</em> |
| 18 |
</p> |
| 19 |
|
| 20 |
<h2>Format</h2> |
| 21 |
|
| 22 |
<pre class="macro-syntax"> |
| 23 |
strmatch <target string> <string with regular expression> |
| 24 |
</pre> |
| 25 |
|
| 26 |
<h2>Remarks</h2> |
| 27 |
|
| 28 |
<p> |
| 29 |
Supports <a href="../../reference/RE.txt">Oniguruma Regular Expressions</a>.<br> |
| 30 |
This command searches the <target string> with the <string with regular expression>.<br> |
| 31 |
|
| 32 |
The "strmatch" command returns one of the following values in the system variable "result": |
| 33 |
</p> |
| 34 |
|
| 35 |
<table> |
| 36 |
<tr> |
| 37 |
<th>Value</th> |
| 38 |
<th>Meaning</th> |
| 39 |
</tr> |
| 40 |
<tr> |
| 41 |
<td>0</td> |
| 42 |
<td>Not matched.</td> |
| 43 |
</tr> |
| 44 |
<tr> |
| 45 |
<td>1</td> |
| 46 |
<td>Matched offset(1origin).</td> |
| 47 |
</tr> |
| 48 |
</table> |
| 49 |
|
| 50 |
<p> |
| 51 |
The first matched pattern is stored in the system variable "matchstr".<br> |
| 52 |
Group matched patterns of regular expressions are stored in 9 system variables from "groupmatchstr1" to "groupmatchstr9".<br> |
| 53 |
Also, these system variables will not be changed when the pattern does not match. |
| 54 |
</p> |
| 55 |
|
| 56 |
<p> |
| 57 |
When a user searches the multi-byte string like as Japanese, the user must configure the regular encoding by using the <a href="regexoption.html">regexoption</a> previously. |
| 58 |
</p> |
| 59 |
|
| 60 |
<h2>Example</h2> |
| 61 |
|
| 62 |
<pre class="macro-example"> |
| 63 |
strmatch 'Microsoft Windows XP [Version 5.1.2600]' '\[(Version (\d+).(\d+).(\d+))\]' |
| 64 |
|
| 65 |
int2str s result |
| 66 |
messagebox s 'result' ; 22 |
| 67 |
messagebox matchstr 'matchstr' ; [Version 5.1.2600] |
| 68 |
messagebox groupmatchstr1 'groupmatchstr1' ; Version 5.1.2600 |
| 69 |
messagebox groupmatchstr2 'groupmatchstr2' ; 5 |
| 70 |
messagebox groupmatchstr3 'groupmatchstr3' ; 1 |
| 71 |
messagebox groupmatchstr4 'groupmatchstr4' ; 2600 |
| 72 |
</pre> |
| 73 |
|
| 74 |
<h2>See also</h2> |
| 75 |
<ul> |
| 76 |
<li><a href="regexoption.html">regexoption</a></li> |
| 77 |
<li><a href="strreplace.html">strreplace</a></li> |
| 78 |
<li><a href="strinsert.html">strinsert</a></li> |
| 79 |
<li><a href="strremove.html">strremove</a></li> |
| 80 |
</ul> |
| 81 |
|
| 82 |
</body> |
| 83 |
</html> |