string.match

  vararg string.match( string string, string pattern, number startPosition = 1 )

Açıklama

Bir string içinde bir Desen bulur.

Argümanlar

1 string string
İçinde eşleşme aranacak olan string.
2 string pattern
Neyin eşleştirileceğini tanımlayan desen.
3 number startPosition = 1
Eşleştirmenin başlayacağı başlangıç indeksi, sondan göreceli bir konumdan eşleştirmeyi başlatmak için negatif olabilir.

Döndürülenler

1 vararg
Eşleşen metin(ler)

Örnek

local toMatch = "this is a sample text" print( string.match( toMatch, "sample" ) ) -- desenler çalışır print( string.match( toMatch, "^[a-z]" ) ) print( string.match( toMatch, "^this" ) ) print( string.match( toMatch, "^..is" ) ) print( string.match( toMatch, "text$" ) ) -- tüm string print( string.match( toMatch, "^.*$" ) ) -- çoklu dönüş değerleri print( string.match( toMatch, "(this) is a (%w+)" ) ) -- nil print( string.match( toMatch, "this$" ) ) print( string.match( toMatch, "nil" ) )
Çıktı:
sample t this this text this is a sample text this sample nil nil

Tüm sunucular · GmodTR Launcher · Rehber · GMod Wiki · GmodTR nedir? · Sunucu ekle · Discord