<input type="text" value="abcd 12s efg"><input type="button" value="ss" onclick="sReplace(previousSibling)">
<script type="text/javascript">
function sReplace(e){
e.value=e.value.replace(/(\d+)s/g , function(a,b) {
return new Array(++b).join('s')
}
)
}
</script>