cStr = "中华人民共和国美335*226利坚合众MF-335国大不7*3列颠"
re = Createobject("VBScript.RegExp")
re.Global = .T.
re.Ignorecase = .T.
re.Pattern = "[\u4e00-\u9fa5]"
**********************************
* 下面代码,返回所有汉字 *
*re.Pattern = "[^\u4e00-\u9fa5]"
****************************
?re.replace(cStr,"")
原文本格式如下:
05 14 15 16 18 + 02 0605 14 15 16 25 + 02 0605 14 15 16 26 + 02 0605 14 15 16 27 + 02 0605 14 15 18 25 + 02 0605 14 15 18 26 + 02 0605 14 15 18 27 + 02 0605 14 15 25 26 + 02 0605 14 15 25 27 + 02 0605 14 15 26 27 + 02 0605 14 16 18 25 + 02 0605 14 16 18 26 + 02 0605 14 16 18 27 ...
因为这几个字符在行中也是出现的,所以肯定不能用简单的替换实现
比如
12345 1265345
2345
需要删除每行末尾的“345”,最终文本为:
12345 1265
2
===================================
Re = Createobject("VBScript.RegExp")
Re.Global = .T.
Re.Ignorecase = .F.
Re.Pattern ="345$"
Re.MultiLine= .T.
cStr="12345 1265345"+CHR(13)+CHR(10)+"2345...
原始文本如下面两行
abc aaaaa
123 abc 444
希望每次遇到“abc”,则替换“abc”以及其后到行尾的内容为“abc efg”
即上面的文本最终替换为:
abc efg
123 abc efg
=====================================
CLEAR
Re = Createobject("VBScript.RegExp")
Re.Global = .T.
Re.Ignorecase = .F.
RE.Pattern ="abc.*"
cStr="abc aaaaa"+CHR(13)+CHR(10)+"123...
希望把
asdadas123asdasdas456asdasdasd789asdasd
替换为:
asdadas[123]asdasdas[456]asdasdasd[789]asdasd
在VFP中也可以做到,但过程比较复杂
CLEAR
Re = Createobject("VBScript.RegExp")
Re.Global = .T.
Re.Ignorecase = .F.
RE.Pattern ="(\d{3})"
cStr="asdadas123asdasdas456asdasdasd789asdasd"
?cStr
?Re.Replace(cS...
查找出 XM 字段中除汉字以外的字符,并替换掉这些字符。
CREATE CURSOR tt (xm c(10),xm1 c(10))
INSERT INTO tt (xm) VALUES ("河南\省")
INSERT INTO tt (xm) VALUES ("河-北省")
INSERT INTO tt (xm) VALUES ("北,22京市")
INSERT INTO tt (xm) VALUES ("上海市")
INSERT INTO tt (xm) VALUES ("西安市")
re = Createobject("VBScript.RegExp")
...
CLEAR
cStr = "苹果:iphone_5s;诺基亚:Nokia_1020"
* 提取出cSrt中的"iphone_5s","Nokia_1020"
Reg = Createobject("VBScript.RegExp")
Reg.Global = .T.
Reg.Ignorecase = .T.
Reg.Pattern = "\w+"
oExec=Reg.Execute(cStr)
FOR i=0 TO oExec.Count-1
?oExec.item(i).Value
ENDFOR
...
* 删除没有空格的空行
clear
cchr=chr(10)+chr(13)
cstr="111111"+replicate(cchr,3)+"222222"+replicate(cchr,5)+"3333333"+replicate(cchr,10)+"4444"
?"====="
?cstr
re = Createobject("VBScript.RegExp")
re.Global = .T.
re.Ignorecase = .T.
re.Pattern = "\r\n" && r 代表回车,n 代表换行
?"====="
?re.replac...
Clear
Text To s Noshow
<tr class='citytr'><td><a href='23/2301.html'>230100000000</a></td><td><a href='23/2301.html'>哈尔滨市</a></td></tr><tr class='citytr'><td><a href='23/2302.html'>230200000000</a></td><td><a href='23/2302.html'>齐齐哈尔市</a></td></tr><tr class='citytr'><td><a href='23/2303.html'...