StringUtils Class Reference

A collection of static methods to play with strings. More...

List of all members.

Static Public Member Functions

static hungryDelimiterReplace ($startDelim, $endDelim, $replace, $subject)
 Perform an operation equivalent to.
static delimiterReplaceCallback ($startDelim, $endDelim, $callback, $subject, $flags= '')
 Perform an operation equivalent to.
static delimiterReplace ($startDelim, $endDelim, $replace, $subject, $flags= '')
static explodeMarkup ($separator, $text)
 More or less "markup-safe" explode() Ignores any instances of the separator inside <.
static escapeRegexReplacement ($string)
 Escape a string to make it suitable for inclusion in a preg_replace() replacement parameter.
static explode ($separator, $subject)
 Workalike for explode() with limited memory usage.


Detailed Description

A collection of static methods to play with strings.

Definition at line 5 of file StringUtils.php.


Member Function Documentation

static StringUtils::delimiterReplace ( startDelim,
endDelim,
replace,
subject,
flags = '' 
) [static]

static StringUtils::delimiterReplaceCallback ( startDelim,
endDelim,
callback,
subject,
flags = '' 
) [static]

Perform an operation equivalent to.

preg_replace_callback( "!$startDelim(.*)$endDelim!s$flags", $callback, $subject )

This implementation is slower than hungryDelimiterReplace but uses far less memory. The delimiters are literal strings, not regular expressions.

Parameters:
string $flags Regular expression flags

Definition at line 46 of file StringUtils.php.

Referenced by delimiterReplace(), LinkMarkerReplacer::expand(), and explodeMarkup().

static StringUtils::escapeRegexReplacement ( string  )  [static]

Escape a string to make it suitable for inclusion in a preg_replace() replacement parameter.

Parameters:
string $string
Returns:
string

Definition at line 165 of file StringUtils.php.

Referenced by Linker::formatLinksInCommentCallback(), MagicWord::replace(), and wfRegexReplacement().

static StringUtils::explode ( separator,
subject 
) [static]

static StringUtils::explodeMarkup ( separator,
text 
) [static]

More or less "markup-safe" explode() Ignores any instances of the separator inside <.

..>

Parameters:
string $separator
string $text
Returns:
array

Definition at line 139 of file StringUtils.php.

References $i, $text, delimiterReplaceCallback(), and explode().

Referenced by wfExplodeMarkup().

static StringUtils::hungryDelimiterReplace ( startDelim,
endDelim,
replace,
subject 
) [static]

Perform an operation equivalent to.

preg_replace( "!$startDelim(.*?)$endDelim!", $replace, $subject );

except that it's worst-case O(N) instead of O(N^2)

Compared to delimiterReplace(), this implementation is fast but memory- hungry and inflexible. The memory requirements are such that I don't recommend using it on anything but guaranteed small chunks of text.

Definition at line 17 of file StringUtils.php.

References $output, $s, and explode().


The documentation for this class was generated from the following file:

Generated on Sat Sep 5 02:08:48 2009 for MediaWiki by  doxygen 1.5.9