<script> var value = "руб.260000"; var out = value.replace(/^(.*?)(\d+)$/g,'$2 $1').replace(/(\d)(?=(\d\d\d)+([^\d]|$))/g, '$1.'); document.write(out) </script>