pregMatch | Multi Theft Auto: Wiki Skip to content

pregMatch

Client-side
Server-side
Shared

This page is incomplete! Help wanted!

Please finish this page using the corresponding Old Wiki article.
Go to Contribution guidelines for more information.


This function returns all matches.

Caution

When declaring a pattern string in quotes, the backslash character should be doubled up. e.g. "\(" will match a single bracket.

Caution

Multiline flag does not work correctly

Syntax

pregMatch ( )

Code Examples

server

Some examples:

addCommandHandler( 'example',
function( )
--[[
Will print:
Match: 1, hello
Match: 2, hello
]]
for i, v in ipairs( pregMatch( "hello hello", "(hello)" ) ) do
outputDebugString( "Match: " .. i .. ", " .. v );
end
end
);
addCommandHandler( 'example2',
function( )
--[[
Will print:
Match: 1, somebodyWWw
Match: 2, 228
]]
for i, v in ipairs( pregMatch( "somebodyWWw\n228", "([a-z0-9]+)", "im" ) ) do
outputDebugString( "Match: " .. i .. ", " .. v );
end
end
);