请高手写一个批处理文件或帮忙找一个字符替换软件软件

来源:百度知道 编辑:UC知道 时间:2024/05/21 20:34:12
有一个txt文件,其中内容为

name:xxx word:xxx
name:xdfax word:xxfdafx
name:xxxfda word:xfdafxx
name:xfdafxx word:xxfdafx

现在想批量把每行的name替换为name****或******,其中****为随机字母或者字母+数字。效果为 name7fd5 或 hay654

另外这样也可以。
把name后的xxx,xdfax,xxxfda这些字母 替换为在其后面加上几个随机字母或者数字。效果变为xxxfd54,xdfaxdaff5f,xxxfda421f这样。

'复制到记事本另存为a.vbs 把你要处理的内容存到a.txt文件里(两个文件在同一目录下)
str=split("A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 0 a b c d e f g h i j k l m n o p q r s t u v w x y z")
set ws=createobject("wscript.shell")
set fso=createobject("scripting.filesystemobject")
set file=fso.opentextfile("a.txt")
do while file.atendofstream<>true
s=s & replace(file.readline,"name","name" & myreplace) & vbcrlf
loop
file.close
set file=fso.createtextfile("#a.txt")
file.write s
file.close
ws.run "#a.txt"
function myreplace()
randomize
h=int(rnd()*4)+3
for i=1 to h
n=int(rnd()*ubound(str))
myreplace=myreplace & str(n)
next
end function

用Replace Pioneer,支持带函数的替换,处理这个问题极简单,只要把name替换成"name".join('',map{('a'..'z',0..9)[rand(36)]}(1..4))就可以了。

===============