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

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

<p>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.</p>

<p>In below string if I have variable two letter string exist I want to append “.new”</p>

<pre><code>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
</code></pre>

<p>Thanks for your help .
Raghav</p>
