javascript 日期格式转换 你这个时间类型是字符串格式的么?replace 不可以么? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 正则定义两种方法:var reg=/\d+/g或者var reg=new RegExp("ain",g);你上边的mon定义成这样"/"+iMonth+"月"+"/g"; 之后又 用new定义 ?? <script>var str="2008年03月28日";var i =0;while(str.indexOf("年")>-1){str = str.replace('年','.');}while(str.indexOf("月")>-1){str = str.replace('月','.');}while(str.indexOf("日")>-1){str = str.replace('日','');}alert(str);</script><body></body> for(iMonth=1;iMonth <=12;iMonth++){ var mon=/^(\d{4})[^\d]+(\d{2})[^\d]+(\d{2}).*$/gstrLog = strLog.replace(mon,"$1.$2.$3"); } var mon = eval("/"+iMonth+"月"+"/g"); strLog = strLog.replace(mon,iMonth); <script type="text/javascript"> var str = "有个时间为 2008年03月14日\n如何转换为 2008.03.14\nfor(iMonth=1;iMonth <=12;iMonth++){\nmon = \"/\"+iMonth+\"月\"+\"/g\";\nstrLog = strLog.replace(new RegExp(mon,\"g\"),iMonth);\n"; var resu; resu = str.replace(/([0-9]{2,4})年([0-9]{1,2})月([0-9]{1,2})日/g,"$1.$2.$3"); alert(resu);</script> JavaScript如何取得html中table的高度 jquery新手问题5 如何让倒计时恢复记时 JS 求帮忙修改问题! 请问如何导出浏览器的收藏夹 关于没有form的页面操作控件 如何捕捉怎么WEB画面上的click事件呀? 大家快帮帮忙,急!!分不够可以再加 关于input focus 请教各位大神javascript获取span的值 new Function()的问题 在text搜索栏里如何像baidu那样保存浏览的历史记录?
<script>
var str="2008年03月28日";
var i =0;
while(str.indexOf("年")>-1){str = str.replace('年','.');}
while(str.indexOf("月")>-1){str = str.replace('月','.');}
while(str.indexOf("日")>-1){str = str.replace('日','');}
alert(str);
</script>
<body>
</body>
for(iMonth=1;iMonth <=12;iMonth++){
var mon=/^(\d{4})[^\d]+(\d{2})[^\d]+(\d{2}).*$/g
strLog = strLog.replace(mon,"$1.$2.$3");
}
strLog = strLog.replace(mon,iMonth);
var str = "有个时间为 2008年03月14日\n如何转换为 2008.03.14\nfor(iMonth=1;iMonth <=12;iMonth++){\nmon = \"/\"+iMonth+\"月\"+\"/g\";\nstrLog = strLog.replace(new RegExp(mon,\"g\"),iMonth);\n";
var resu;
resu = str.replace(/([0-9]{2,4})年([0-9]{1,2})月([0-9]{1,2})日/g,"$1.$2.$3");
alert(resu);
</script>