string.match
From GMod Wiki
| Function | |
| Syntax |
string.match( Where is this used? |
| Description: | |
|
If it finds a match in the pattern, it returns that. Otherwise, it will return |
|
| Returns: |
|
| Part of Library: |
|
| Available On: |
|
| BBCode Link: | [b][url=http://wiki.garrysmod.com/?title=String.match]String.match [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b] |
Examples
| Description | Shows the use of multiple captures. |
|---|---|
| Used on | |
| Code | local a = "one: two" local one,two = string.match(a, "(%l*): (%l*)") print("One: " .. one .. ", two: " .. two); |
| Output | One: one, two: two |
Additional Notes
- This is like string.find, but it returns the matched string instead of an
.
- Allows the usage of Regular Expressions.
- If () captures are used, it will return each of the captures as a separate value
