From: Patrick May
Date: 2004-09-05T04:26:57+09:00
Subject: Re: OK... :) question about hash and array literals
Hello,
My main use for using ordered hashes is to express repeated regexp
string transformations. For example, in php I use this series of
regexp's to clean up html spacing:
foreach( array( '/\n|\f|\r/' => " ",
'/\s+/' => " ",
'/\s*<\/p>/i' => "
",
'/<( )?\/p>/i' => "",
'/
/i' => "\n\n
",
'/
$/i' => "", ) as $p => $r ) {
$string = preg_replace( $p, $r, $string );
}
There are of course other uses, but has been a real handy one for me.
Cheers,
Patrick