Difference between revisions of "String.match"
From GiderosMobile
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
− | '''Available since:''' Gideros 2011.6<br/> | + | '''<translate>Available since</translate>:''' Gideros 2011.6<br/> |
− | === Description === | + | === <translate>Description</translate> === |
<translate>Find the first match of the regular expression "pattern" in "str", starting at position "index". | <translate>Find the first match of the regular expression "pattern" in "str", starting at position "index". | ||
Line 17: | Line 17: | ||
(string) = string.match(string,pattern) | (string) = string.match(string,pattern) | ||
</source> | </source> | ||
− | === Parameters === | + | === <translate>Parameters</translate> === |
'''string''': (String) <translate>Any string.</translate> <br/> | '''string''': (String) <translate>Any string.</translate> <br/> | ||
'''pattern''': (String) <translate>Specifies the pattern to match.</translate> <br/> | '''pattern''': (String) <translate>Specifies the pattern to match.</translate> <br/> | ||
− | === Return values === | + | === <translate>Return values</translate> === |
− | '''Returns''' (string) <translate>String matching pattern.</translate><br/> | + | '''<translate>Returns</translate>''' (string) <translate>String matching pattern.</translate><br/> |
Revision as of 07:26, 24 August 2018
Available since: Gideros 2011.6
Description
Find the first match of the regular expression "pattern" in "str", starting at position "index".
The starting position (index) is optional, and defaults to 1 (the start of the string).
If found, returns any captures in the pattern. If no captures were specified the entire matching string is returned.
If not found, returns nil.
This is similar to string.find, except that the starting and ending index are not returned.
print (string.match ("You see dogs and cats", "s..")) --> see
(string) = string.match(string,pattern)
Parameters
string: (String) Any string.
pattern: (String) Specifies the pattern to match.
Return values
Returns (string) String matching pattern.