在Delphi中使用正则表达式
//参考地址:http://www.wangchao.net.cn/bbsdetail_41190.html
一、微软RegExp
1. 下载并安装最新版的"Microsoft(r) Windows(r) Script"
2. RegExp包含在vbscript.dll中所以我们必须先注册regsvr32 vbscript.dll
注(安装了Ie5后默认已经包含该控件)
3.在Delphi中引入"Microsoft VBScript Regular Expressions"
主菜单->Project->Import type library->在列表中选择"Microsoft VBScript Regular Expressions"
生成TRegExp控件
4.使用以下代码调用TRegExp控件
二、代码:
procedure TForm1.Button1Click(Sender: TObject);
var
machs: IMatchCollection;
Matchs: Match;
submatch: ISubMatches;
i, j: integer;
begin
RegExp1.Global := true;
RegExp1.Pattern := '\w+\.\w+(?!.)';
RegExp1.IgnoreCase := true;
machs := RegExp1.Execute('http://www.xcolor.cn/dd/page1.htm') as
IMatchCollection;
for i := 0 to machs.Count - 1 do
begin
Matchs := machs.Item[i] as Match;
submatch := Matchs.SubMatches as ISubMatches;
memo1.Lines.Add(matchs.Value);
//for j:=0 to submatch.Count -1 do
// memo1.Lines.Add(submatch.Item[j])
end;
end;
相关文档:
一年前开发了一个MIDAS的程序,最近修改服务端,可是这个服务无法注册,最后终于找到了解决办法,这个相关文章如下:(算是备份吧)
(一)MIDAS是什么?
Delphi中MIDAS到底是什么呢?和他相关组件是什么呢?
MIDAS(Multitiered Distributed Application Services)多层分布式应用服务。
Delphi所提出 ......
以前看了 通过崩溃地址找错误行数之VC版 那时候还没用DELPHI
昨晚刚好又看到了 所以就试了一下DELPHI的,与大家共享 ^_^
什么是 MAP 文件?简单地讲, MAP 文件是程序的全局符号、源文件和代码行号信息的唯一的文本表示方法,它可以在任何地方、任何时候使用,不需要有额外的程序进行支持。而且,这是唯一能找出程 ......
The built-in assembler allows you to write assembly code within Delphi programs. It has the following features:
内嵌的汇编器允许在delphi程序中书写汇编代码,他有如下特性:
Allows for inline assembly
允许内嵌汇编
Supports all instructions found in the Intel Pentium III, In ......
最近要做一个图书管理系统,并且是用Delphi软件开发,很多都不懂,本来是可以从网上下载,学习一下的,可是不知道怎么破解登陆密码,运行时没办法登陆进去,5555~~好好学习,有高手指点就好了…… ......
Ctrl+PageUp 将光标移至本屏的第一行,屏幕不滚动。
Ctrl+PageDown 将光标移至本屏的最后一行,屏幕不滚动。
Ctrl+↓ 向下滚动屏幕,光标跟随滚动不出本屏。
Ctrl+↑ &nb ......