ServersYour serverFor creatorsForumFAQDocumentationSecurity
Download the launcher
  1. Documentation
  2. Server functions
  3. pregFind

Function

pregFind

ServerUtilitiesIdentical to MTA:SA

Checks whether a text matches a regular expression (JavaScript syntax). Flags as text ("i" - case-insensitive, "m" - multiline, "s" - dot matches newline, "u" - Unicode) or a number.

Syntax

bool pregFind(string subject, string pattern [, string/int flags = ""])

Arguments

subjectstring
The text.
patternstring
Regular expression.
flagsstring/int, optional = ""
Flags.

Returns

true when it matches.

Example

addEventHandler("onPlayerChat", root, function(message)
    if pregFind(message, "\\b(cheat|hack)\\b", "i") then
        cancelEvent()
        outputChatBox("Nie pisz o cheatach", source)
    end
end)

See also