字符串转换---之 输出问题
1,复制进附件 into.txt文件内容。2,点转换
3,想实现以下修改
1》 实现out.txt的输出,让sb1的输出整齐。
我想是否是用if语句把第三列当“-”时增加输出呢?
2》实现让第二列,2,2,2,4,4,2,2,2,2,2,2,2这一列输出的值全部除以第一个494329-b21的值2,当这一列改变为3时,除以3。这个问题不值如何解决。

[ 本帖最后由 chiangs 于 2010-8-9 11:21 编辑 ]
<html> <title>CCA Tool for Eclipse</title> <head> <script type="text/javascript"> function replaceAll(v, a, b) { x = v; while (x.indexOf(a) != -1) { x = x.replace(a, b); } return x; } function trans(v) { var lines = v.split("\r\n"); var r = ""; for (i = 0, sb = 0, p = false; i < lines.length - 1; i++) { if (lines[i].substr(0, 3) != "ISS") { p = false; continue; } if (p == false) { p = true, sb++; } var line = lines[i].split(" "); if (line[0] == "ISS") { r += line[1] + "\t" + line[2] + "\t" + line[5] + "\t" + line[7] + "\tsb" + sb + "\r\n"; } else { var rec = /^[0-9]{1}$/; for (var j = 0; j < line.length; j++) { if (rec.test(line[j])) { r += line[1] + "\t" + line[j] + "\t" + line[j+4] + "\tsb" + sb + "\r\n"; } } } } return r; } function click_event() { document.getElementById('de').value = trans(document.getElementById('sc').value); document.getElementById('de').focus(); document.getElementById('de').select() } function clearfn() { document.getElementById('sc').value = ''; document.getElementById('de').value = '' } </script> </head> <body> <p>功能:将CCA的IIS CTO产品AV#转变为可以直接导入Eclipse系统的格式</p> <p>使用方法:1,在上区域放入要处理的文本;2,点击“转化”按钮;3,在下域中会得到结果并自动被选中</p> <textarea name="sc" id="sc" style="width:900;height:200" wrap="off"></textarea> <BR> <button onclick="click_event()">转化</button> <button onclick="clearfn()">清空</button> <BR> <textarea name="de" id="de" style="width:900;height:200" wrap="off"></textarea> </body> <html>
<html> <title>CCA Tool for Eclipse</title> <head> <script type="text/javascript"> function replaceAll(v, a, b) { x = v; while (x.indexOf(a) != -1) { x = x.replace(a, b); } return x; } function trans(v) { var lines = v.split("\r\n"); var r = ""; for (i = 0, sb = 0, p = false; i < lines.length - 1; i++) { if (lines[i].substr(0, 3) != "ISS") { p = false; continue; } if (p == false) { p = true, sb++; } var rec = /^[0-9]{1}$/; var rec_kg = /^[ ]{1,}$/; //过滤数组中值为一个或多个空格的数组元素 var line = lines[i].split("\t"); var line_arr = new Array(); for (var k = 0; k < line.length; k++) { if (!rec_kg.test(line[k]) && line[k]) { //alert(line[k]); line_arr.push(line[k]); //将非空格和非空元素插入新的数组 } } if (line_arr[0] == "ISS") { //alert(line_arr[1]);return; r += line_arr[1] + "\t" + line_arr[3] + "\t" + line_arr[5] + "\tsb" + sb + "\r\n"; } else { for (var j = 0; j < line_arr.length; j++) { if (rec.test(line_arr[j])) { r += line_arr[1] + "\t" + line_arr[j] + "\t" + line_arr[j + 4] + "\tsb" + sb + "\r\n"; } } } } return r; } function click_event() { document.getElementById('de').value = trans(document.getElementById('sc').value); document.getElementById('de').focus(); document.getElementById('de').select() } function clearfn() { document.getElementById('sc').value = ''; document.getElementById('de').value = '' } </script> </head> <body> <p>功能:将CCA的IIS CTO产品AV#转变为可以直接导入Eclipse系统的格式</p> <p>使用方法:1,在上区域放入要处理的文本;2,点击“转化”按钮;3,在下域中会得到结果并自动被选中</p> <textarea name="sc" id="sc" style="width:900;height:200" wrap="off"></textarea> <BR> <button onclick="click_event()">转化</button> <button onclick="clearfn()">清空</button> <BR> <textarea name="de" id="de" style="width:900;height:200" wrap="off"></textarea> </body> <html>试试吧。