有人告诉我用正则表达式,可是我一时还用不明白,请达人指教
解决方案 »
- 高分求助!!!!!!!!!请问如何在普通的tableView中实现主从表的效果?!!在线等
- 【Delphi爱好者大聚会,欢迎大家加入delphi技术讨论群】
- 俺看到最垃圾的深圳地图,大家千万“深圳易图”的当。。。。
- 这句话为什么在Delphi 7中报错?
- 请问能否把table的第一个字段(A)的属性设为readonly,不能修改,而第二个字段能够edit呢?如何弄呢?
- 如何注册一个OCX控件?
- 连续分段存储,请各位大侠帮忙,有高分呀!!在线等待。。。
- 有一个网站开出的招聘信息很诱人哦,进来看看
- 如何判断edit1.text输入的值(密码)和INI文件(密码)相同。用语句写
- 制作共享软件用什么语言开发比较好
- 谁有详细的WindowAPI编程的电子书
- dbgrid 的问题?高手帮忙!!!
// ??
最佳匹配呀...不太懂得意思..正则表达式..当年编译原理没学好呀....
s:string;
r:string;
begin
s := ' a审批a审 批d 人';
r := 'var r = new RegExp("审.{0,2}批.{0,2}人", "g");' +
#13#10'var s = ' + QuotedStr(s) +
#13#10's.match(r).join("")' ;
ShowMessage(VarToStr(ScriptControl1.Eval(r)));
end;
//替换用 #13#10's.replace(r, "要替换为的文字")' ;
//new RegExp("审.{0,2}批.{0,2}人", "g"); 这就是正则表达式,研究一下吧。
.表示任意字符
{0,2}表示在“审”与“批”之间有0到2个字符
g表示查找所有匹配
#13#10'r.exec(s).index' ;
和
#13#10'r.exec(s).lastIndex' ;
就用
Selection.Find.Execute(FindText:='');
''里加你想要的字符串可以加空格
这是OLE掉用的,不知道符不符合你的要求。
我就是用如下的办法:var
FindText,MatchCase,MatchWholeWord,MatchWildcards,MatchSoundsLike,
MatchAllWordForms,Oforward,Wrap,Format,ReplaceWith,Replace,WordApp,
Matchchashida,MatchDiacritics,Matchalef,MatchControl:Variant;
fordoc:Variant;
i:integer;
s:string;
begin
OleContainer2.DoVerb(0);
OleContainer2.Run;
WordApplication1.Connect;
fordoc:=WordApplication1.ActiveDocument;
matchcase := false;
matchwholeword := true;
matchwildcards := false;
matchsoundslike := false;
matchallwordforms := false;
Oforward:= true;
wrap:=1;
format:= true
replace:= true;
Matchchashida:=false;
MatchDiacritics:=false;
Matchalef:=false;
MatchControl:=false;
replacewith:='要替换的字符';s:='';
for i:=1 to 10 do //最大找10个空格
begin
findtext:='审's+'批'; //呵呵,我只找“审批”
fordoc.range.find.execute( findtext, matchcase, matchwholeword,
matchwildcards, matchsoundslike, matchallwordforms, Oforward,
wrap, format, replacewith, replace,
matchchashida,matchdiacritics,matchalef, matchcontrol);
s:=s+' ';
end;