Difference between revisions of "Utf8.find"

From GiderosMobile
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
__NOTOC__
 
__NOTOC__
'''<translate>Available since</translate>:''' Gideros 2016.06<br/>
+
'''Available since:''' Gideros 2016.06<br/>
'''<translate>Class</translate>:''' [[Special:MyLanguage/utf8|utf8]]<br/>
+
'''Class:''' [[utf8]]<br/>
=== <translate>Description</translate> ===
+
 
<translate>Looks for the first match of pattern in the string s. If it finds a match, then find returns the indices of s where this occurrence starts and ends; otherwise, it returns nil. A third, optional numerical argument init specifies where to start the search; its default value is 1 and can be negative. A value of true as a fourth, optional argument plain turns off the pattern matching facilities, so the function does a plain "find substring" operation, with no characters in pattern being considered magic. Note that if plain is given, then init must be given as well.
+
=== Description ===
If the pattern has captures, then in a successful match the captured values are also returned, after the two indices.</translate>
+
Looks for the first match of pattern in the string s.
<source lang="lua">
+
<syntaxhighlight lang="lua">
 
(numbers) = utf8.find(s,pattern,init,plain)
 
(numbers) = utf8.find(s,pattern,init,plain)
</source>
+
</syntaxhighlight>
=== <translate>Parameters</translate> ===
+
 
'''s''': (string) <translate></translate> <br/>
+
If it finds a match, then find returns the indices of s where this occurrence starts and ends; otherwise, it returns nil.
'''pattern''': (string) <translate></translate> <br/>
+
 
'''init''': (number) <translate></translate> '''optional'''<br/>
+
A third, optional numerical argument init specifies where to start the search; its default value is 1 and can be negative.
'''plain''': (boolean) <translate></translate> '''optional'''<br/>
+
 
=== <translate>Return values</translate> ===
+
A value of true as a fourth, optional argument plain turns off the pattern matching facilities, so the function does a plain "find substring" operation, with no characters in pattern being considered magic. Note that if plain is given, then init must be given as well.
'''<translate>Returns</translate>''' (numbers) <translate>the indices of s where this occurrence starts and ends; otherwise, it returns nil</translate><br/>
+
 
 +
If the pattern has captures, then in a successful match the captured values are also returned, after the two indices.
 +
 
 +
=== Parameters ===
 +
'''s''': (string) <br/>
 +
'''pattern''': (string) <br/>
 +
'''init''': (number) '''optional'''<br/>
 +
'''plain''': (boolean) '''optional'''<br/>
 +
 
 +
=== Return values ===
 +
'''Returns''' (numbers) the indices of s where this occurrence starts and ends; otherwise, it returns nil<br/>
 +
 
 +
{{Utf8}}

Latest revision as of 21:46, 1 December 2023

Available since: Gideros 2016.06
Class: utf8

Description

Looks for the first match of pattern in the string s.

(numbers) = utf8.find(s,pattern,init,plain)

If it finds a match, then find returns the indices of s where this occurrence starts and ends; otherwise, it returns nil.

A third, optional numerical argument init specifies where to start the search; its default value is 1 and can be negative.

A value of true as a fourth, optional argument plain turns off the pattern matching facilities, so the function does a plain "find substring" operation, with no characters in pattern being considered magic. Note that if plain is given, then init must be given as well.

If the pattern has captures, then in a successful match the captured values are also returned, after the two indices.

Parameters

s: (string)
pattern: (string)
init: (number) optional
plain: (boolean) optional

Return values

Returns (numbers) the indices of s where this occurrence starts and ends; otherwise, it returns nil