<script> var str = 'olololo2013oololo' var year = str.match(/2013/)[0] - 1 str = str.replace(/2013/, year) alert(str) </script>