regex/jquery to find domain(url) in div and append parameter
===

[Previous stackoverflow][1]

This jquery statement will look for domain.com and append ?parameter to the end of the URL. It will NOT append if ?parameter has already been added.

The problem: My current jquery modifies all URLs and not domain.com. Here is the regex statement that i would like to use and is tested to work. However, when implemented, nothing is appended. Any help is greatly appreciated!

Regex i would like to use:

    \b(https?://)?([a-z0-9-]+\.)*domain\.com(/[^\s]*)?
[RegexFiddle][2]

[JSFiddle][3] for convience

Code to be modified

    <div id="wp-content-editor-container" class="wp-editor-container"><textarea class="wp-editor-area" rows="10" tabindex="1" cols="40" name="content" id="content">&lt;a title="Link to test domain" href="http://www.domain.com"&gt;Link to google&lt;/a&gt;
    &lt;a href="http://www.google.com/directory/subdirectory/index.html"&gt;This is another link&lt;/a&gt;
    &lt;a href="http://domain.com/directory/index.html"&gt;This is a 3rd link&lt;/a&gt;
    
    &lt;a href="http://www.domain.com/subdir?parameter"&gt;this url already has parameters&lt;/a&gt;</textarea></div>
current jquery statement

    var url = 'www.domain.com';
    var append = '?parameter';
    
    $(".wp-editor-area").each(function() {
        $(this).text(urlify($(this).text()));
    });
    
    function urlify(text) {
        var urlRegex = /(\b(https?|ftp|file):\/\/[www.domain.com][-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
        return text.replace(urlRegex, function(url) {
            // if the url does not contain append, concat append to the URL
            if (url.indexOf(append) == -1) {
                return url + append;
            }
            return url;
        });
    
    }


Current output

        <a title="Link to test domain" href="http://www.domain.com?parameter">Link to google</a>
    <a href="http://www.google.com/directory/subdirectory/index.html?parameter">This is another link</a>
    <a href="http://domain.com/directory/index.html?parameter">This is a 3rd link</a>


  [1]: http://stackoverflow.com/questions/11422274/jquery-to-identify-url-and-append-parameters
  [2]: http://fiddle.re/6gwv
  [3]: http://jsfiddle.net/nJCtC/