Regular expression for replacing string with javascript
I need help in writing regular expression:  
part of my string is fixed and another part of its variable.

only if fixed AND variable string exist i need to alter the string other wise no.

Fixed string:example: AA.BBB.COM 
Variable string (may or mayn't exist ): US, but if exist it will be always two letter string with any combination of letter.
 
In below string if I have variable two letter string exist I want to append “.new”

    1 ) https://XY**.US**.AA.BBB.COM
     Output:  https:// XYZ12**.US.NEW**.AA.BBB.COM

    2 ) https://XY.UK.AA.BBB.COM
     Output:  https:// XYZ12.UK.NEW.AA.BBB.COM

    3) https://XY.AA.BBB.COM  (no variable string so no change)
     Output:  https:// XY.AA.BBB.COM

Thanks for your help .
Raghav

Regular expression for replacing string with javascript
===

I need help in writing regular expression:  
part of my string is fixed and another part of its variable.

only if fixed AND variable string exist i need to alter the string other wise no.

Fixed string:example: AA.BBB.COM 
Variable string (may or mayn't exist ): US, but if exist it will be always two letter string with any combination of letter.
 
In below string if I have variable two letter string exist I want to append “.new”

    1 ) https://XY**.US**.AA.BBB.COM
     Output:  https:// XYZ12**.US.NEW**.AA.BBB.COM

    2 ) https://XY.UK.AA.BBB.COM
     Output:  https:// XYZ12.UK.NEW.AA.BBB.COM

    3) https://XY.AA.BBB.COM  (no variable string so no change)
     Output:  https:// XY.AA.BBB.COM

Thanks for your help .
Raghav
