jQuery toggle text function need suggestion
<p>I'm extending jQuery to add Toggle Text method. for which I'm passing two texts which has to be toggled with each other. Which will take any part of the text and replace with the given one. I've written the following code snippet. </p>

<pre><code>$.fn.toggleText  = function( text1, text2 ) {
    return this.each( function() {
        $element = $( this );
        $text = $element.text();
        var re1 = new RegExp( text1.replace(/([.?*+^$[\]\\(){}-])/g, "\\$1"), "ig" );
        var re2 = new RegExp( text2.replace(/([.?*+^$[\]\\(){}-])/g, "\\$1"), "ig" );
        $element.text( ( re1.test( $text ) ) ? $text.replace( re1, text2 ) : $text.replace( re2, text1 ) );
    });
}
</code></pre>

<p>Usage <code>$( "#toggle_test, #toggle_test1, #toggle_test2" ).toggleText('Hello', "Hi");</code> This will replace any <code>hello</code>  text with <code>hi</code> in the all the selected elements.</p>

<p>Please give me your valuable suggestion and correct me if I'm wrong. </p>
