var str='/choose/sg-m/';
console.log(insertRid(str,1));

function insertRid(str,rid){
			var splits =str.split('/');
			if(splits.length==2)
				return str+'r'+rid+'/';

			var resStr='';
			var length=splits.length;
			for(var i=0; i<length; i++){
				console.log(resStr);

				if(i==0){
					// do nothing
				}else if(i==2){
					resStr+='/r'+rid+'/'+splits[i];
				}else{
					resStr+='/'+splits[i];
				}
			}
			return resStr;
		}