From: Robert Klemme
<( )?\/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. In this case nested arrays are sufficient since you don't need efficient lookup. The only access is iteration as far as I can see. Example: transformations = [ [/foo/, "bar"], [/baz/, "xxx"], [/\s+/, " "], ] text = "xxx foo ddddd bar bazsiud" transformations.each {|rx, repl| text.gsub!(rx, repl) } Kind regards robert