Zum Inhalt springen
Magp.ie

Schlagwort: strings

Regular expression to remove excess whitespace

Neat way of removing excess whitespace and tabbing from strings.

[source language=“php“]
$string = "Tom\tThumb\t is sooooooo\t\t\tdumb";
$string = preg_replace( ‚/\s+/‘, ‚ ‚, $string );
echo $string;
//will echo "Tom Thumb is sooooooo dumb"
[/source]

Eoin Code Kommentar hinterlassen Januar 30, 2011Januar 31, 2011

Tags

array associative array bash cheat sheet coda command commands cross-browser css CSV cURL debug debugging techniques developer debug tool duplicates encoding ExternalInterface filters Flash format github Gmail guide html javascript jQuery linux LSO Mac OSX MySQL online tools php plugin regex regular expression screen scripting search shortcuts SSH Sublime Text SVN tar terminal textwrangler tips UTF8 wordpress WordPress coding standards XML

Schließe dich 629 anderen Abonnenten an
Bereitgestellt von WordPress.com.
 

Kommentare werden geladen …