# Javascript Regular Expression Help

**URL:** <https://forum.kirupa.com/t/javascript-regular-expression-help/284614>\
**Category:** web dev\
**Created:** [March 20, 2009, 9:55pm UTC](https://forum.kirupa.com/t/javascript-regular-expression-help/284614 "2009-03-20T21:55:56Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![pconceptions](https://avatars.discourse-cdn.com/v4/letter/p/b3f665/32.png) [@pconceptions](https://forum.kirupa.com/u/pconceptions)\
**Post date:** [March 20, 2009, 9:55pm UTC](https://forum.kirupa.com/t/javascript-regular-expression-help/284614/1 "2009-03-20T21:55:56Z")

</div>

Hello!

I’ve been struggling with this for a while and I need a bit of help.

I have and application where a regexp needs to search for a specific word. However, I also want this to be found and replaced when there is a comma or space (and an additional word) after it.

Example.

If I type “Realtor” it replaces it with “Realtor®”  
If I type, “Realtor, Manager” it replaces it with “Realtor®, Manager”

I have everything except the second one working. My regexp is as follows:

```auto
var txtarr = new Array();    
    var regex = /((Realtor-Associate)$|(Realtors)$|(Realtor)$)+/gi; 
        function realtorFixer(regex, textIn){
         var txtarr = textIn.split(",");
        if(!regex.test(textIn)){
        return result = textIn;
        }else {
        var isReal = function(txtarr) {
             return String(txtarr).match(regex);
        }
        var oddArray1=txtarr.filter(isReal)+'\u00AE';
        var oddArray2=txtarr.filter(isReal)
        return result = textIn.replace(oddArray2, oddArray1);
        
        }
    
    }

```

Any help would be greatly appreciated.
