class Strings

String tools library.

Methods

__construct()

Static class - cannot be instantiated.

static bool
checkEncoding($s)

Checks if the string is valid for UTF-8 encoding.

static string
fixEncoding($s)

Removes invalid code unit sequences from UTF-8 string.

static string
chr($code)

Returns a specific character in UTF-8.

static bool
startsWith($haystack, $needle)

Starts the $haystack string with the prefix $needle?

static bool
endsWith($haystack, $needle)

Ends the $haystack string with the suffix $needle?

static bool
contains($haystack, $needle)

Does $haystack contain $needle?

static string
substring($s, $start, $length = NULL)

Returns a part of UTF-8 string.

static string
normalize($s)

Removes special controls characters and normalizes line endings and spaces.

static string
normalizeNewLines($s)

Standardize line endings to unix-like.

static string
toAscii($s)

Converts to ASCII.

static string
webalize($s, $charlist = NULL, $lower = TRUE)

Converts to web safe characters [a-z0-9-] text.

static string
truncate($s, $maxLen, $append = "…")

Truncates string to maximal length.

static string
indent($s, $level = 1, $chars = "\t")

Indents the content from the left.

static string
lower($s)

Convert to lower case.

static string
upper($s)

Convert to upper case.

static string
firstUpper($s)

Convert first character to upper case.

static string
capitalize($s)

Capitalize string.

static bool
compare($left, $right, $len = NULL)

Case-insensitive compares UTF-8 strings.

static string
findPrefix($strings)

Finds the length of common prefix of strings.

static int
length($s)

Returns number of characters (not bytes) in UTF-8 string.

static string
trim($s, $charlist = " \t\n\r\x00\v ")

Strips whitespace.

static string
padLeft($s, $length, $pad = ' ')

Pad a string to a certain length with another string.

static string
padRight($s, $length, $pad = ' ')

Pad a string to a certain length with another string.

static string
reverse($s)

Reverse string.

static 
random($length = 10, $charlist = '0-9a-z') deprecated

Use Nette\Utils\Random::generate

static array
split($subject, $pattern, $flags = 0)

Splits string by a regular expression.

static mixed
match($subject, $pattern, $flags = 0, $offset = 0)

Performs a regular expression match.

static array
matchAll($subject, $pattern, $flags = 0, $offset = 0)

Performs a global regular expression match.

static string
replace($subject, $pattern, $replacement = NULL, $limit = -1)

Perform a regular expression search and replace.

static 
pcre($func, $args)

No description

Details

at line 24
final __construct()

Static class - cannot be instantiated.

at line 35
static bool checkEncoding($s)

Checks if the string is valid for UTF-8 encoding.

Parameters

$s

Return Value

bool

at line 49
static string fixEncoding($s)

Removes invalid code unit sequences from UTF-8 string.

Parameters

$s

Return Value

string

at line 68
static string chr($code)

Returns a specific character in UTF-8.

Parameters

$code

Return Value

string

at line 83
static bool startsWith($haystack, $needle)

Starts the $haystack string with the prefix $needle?

Parameters

$haystack
$needle

Return Value

bool

at line 95
static bool endsWith($haystack, $needle)

Ends the $haystack string with the suffix $needle?

Parameters

$haystack
$needle

Return Value

bool

at line 107
static bool contains($haystack, $needle)

Does $haystack contain $needle?

Parameters

$haystack
$needle

Return Value

bool

at line 120
static string substring($s, $start, $length = NULL)

Returns a part of UTF-8 string.

Parameters

$s
$start
$length

Return Value

string

at line 141
static string normalize($s)

Removes special controls characters and normalizes line endings and spaces.

Parameters

$s

Return Value

string

at line 163
static string normalizeNewLines($s)

Standardize line endings to unix-like.

Parameters

$s

Return Value

string

at line 174
static string toAscii($s)

Converts to ASCII.

Parameters

$s

Return Value

string ASCII

at line 210
static string webalize($s, $charlist = NULL, $lower = TRUE)

Converts to web safe characters [a-z0-9-] text.

Parameters

$s
$charlist
$lower

Return Value

string

at line 229
static string truncate($s, $maxLen, $append = "…")

Truncates string to maximal length.

Parameters

$s
$maxLen
$append

Return Value

string

at line 254
static string indent($s, $level = 1, $chars = "\t")

Indents the content from the left.

Parameters

$s
$level
$chars

Return Value

string

at line 268
static string lower($s)

Convert to lower case.

Parameters

$s

Return Value

string

at line 279
static string upper($s)

Convert to upper case.

Parameters

$s

Return Value

string

at line 290
static string firstUpper($s)

Convert first character to upper case.

Parameters

$s

Return Value

string

at line 301
static string capitalize($s)

Capitalize string.

Parameters

$s

Return Value

string

at line 314
static bool compare($left, $right, $len = NULL)

Case-insensitive compares UTF-8 strings.

Parameters

$left
$right
$len

Return Value

bool

at line 332
static string findPrefix($strings)

Finds the length of common prefix of strings.

Parameters

$strings

Return Value

string

at line 358
static int length($s)

Returns number of characters (not bytes) in UTF-8 string.

That is the number of Unicode code points which may differ from the number of graphemes.

Parameters

$s

Return Value

int

at line 370
static string trim($s, $charlist = " \t\n\r\x00\v ")

Strips whitespace.

Parameters

$s
$charlist

Return Value

string

at line 384
static string padLeft($s, $length, $pad = ' ')

Pad a string to a certain length with another string.

Parameters

$s
$length
$pad

Return Value

string

at line 399
static string padRight($s, $length, $pad = ' ')

Pad a string to a certain length with another string.

Parameters

$s
$length
$pad

Return Value

string

at line 412
static string reverse($s)

Reverse string.

Parameters

$s

Return Value

string

at line 422
static random($length = 10, $charlist = '0-9a-z') deprecated

deprecated

Use Nette\Utils\Random::generate

Parameters

$length
$charlist

at line 435
static array split($subject, $pattern, $flags = 0)

Splits string by a regular expression.

Parameters

$subject
$pattern
$flags

Return Value

array

at line 449
static mixed match($subject, $pattern, $flags = 0, $offset = 0)

Performs a regular expression match.

Parameters

$subject
$pattern
$flags
$offset

Return Value

mixed

at line 468
static array matchAll($subject, $pattern, $flags = 0, $offset = 0)

Performs a global regular expression match.

Parameters

$subject
$pattern
$flags
$offset

Return Value

array

at line 490
static string replace($subject, $pattern, $replacement = NULL, $limit = -1)

Perform a regular expression search and replace.

Parameters

$subject
$pattern
$replacement
$limit

Return Value

string

at line 512
static pcre($func, $args)

internal  
 

No description

Parameters

$func
$args