PregFind

From Multi Theft Auto: Wiki
Revision as of 12:23, 25 February 2013 by Kenix1 (talk | contribs) (Created page with "__NOTOC__ {{Server client function}} This function find only one match and when match is founded stop working and return a result. ==Syntax== <syntaxhighlight lang="lua"> bool pregFind ( strin...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This function find only one match and when match is founded stop working and return a result.

Syntax

bool pregFind ( string base, string pattern )

Required Arguments

  • base: The base string for find match.
  • pattern: The pattern for find in base string.

Returns

Returns an bool if the function was successful found one match, false otherwise.


Example

Click to collapse [-]
Client

Some examples:

addCommandHandler( 'examples',
	function( )
                -- hello words find
		outputDebugString( pregFind( 'hello world, hello world, hello world', 'hello world' ) or 'not found' ) -- true 
                -- integer number find
                outputDebugString( pregFind( '123', '^-{0,1}\\d+$' ) or 'not found' ) -- true
                -- Login with a-z and A-Z symbols and have more 3 symbols
                outputDebugString( pregFind( 'Kenix', '[a-zA-Z]{3,}' ) or 'not found' ) -- true
                -- Russian hello ( привет ) find
                outputDebugString( pregFind( 'привет привет', 'привет' ) or 'not found' ) -- true
                -- Sequence of numbers
                outputDebugString( pregFind( '5, 10', '^([1-9]{1}[0-9]{0,})+(((,\s|,)[1-9]{1}[0-9]{0,}){0,1}){1,1}' ) or 'not found' ) -- true
	end
)

See Also