var s='<script src="http://code.jquery.com/jquery-latest.js"></script\>'; alert(s.replace(/(src=(")|href=")[^"]+"/gi,'$1url$2'));