qazwsxedc 发表于 2015-6-19 08:47:42

已解决 有多个定位字符时,如何用正则捕获

本帖最后由 qazwsxedc 于 2015-7-2 11:22 编辑

字符串中有2句,但有4个‘.’,如何用正则捕获?
"Ceramics are not typically formed from the melt. This is because most ceramics will crack extensively (i.e. form a powder) upon cooling from the liquidstate."

haijie1223 发表于 2015-6-19 10:37:15

你要捕获什么?捕获点还是字符串?还是捕获罪犯?还是捕获野生动物?

cbslp 发表于 2015-6-23 10:00:14

很好!很强大!











http://www.discuz.net/static/image/common/sigline.gif
http://tinypic.com/a/a5eki/3
http://tinypic.com/a/a5ekj/3
http://tinypic.com/a/a5ekk/3
http://tinypic.com/a/a5ekl/3
http://tinypic.com/a/a5ekm/3
http://tinypic.com/a/a5ekn/3
http://tinypic.com/a/a5eko/3
http://tinypic.com/useralbum.php?ua=REAeLVmqyNB0nA1ffacfVw%3D%3D
http://tinypic.com/a/a5ekw/3
http://tinypic.com/useralbum.php?ua=REAeLVmqyNCl3vDG0Ap4nw%3D%3D
http://tinypic.com/a/a5eky/3
http://tinypic.com/a/a5ekz/3
http://tinypic.com/a/a5el0/3
http://tinypic.com/a/a5el1/3
http://tinypic.com/useralbum.php?ua=REAeLVmqyNA3meUky8U0hg%3D%3D
http://tinypic.com/a/a5el3/3
http://tinypic.com/useralbum.php?ua=REAeLVmqyNCOf4QNYEmDtw%3D%3D

www378660084 发表于 2015-6-23 17:51:39

就你上面这个字符串的话,下面这个可以分出两个句子..


#include <array.au3>

$str = "Ceramics are not typically formed from the melt. This is because most ceramics will crack extensively (i.e. form a powder) upon cooling from the liquidstate."

$arr = StringRegExp($str,"(?:[^()]|(?:\(.+\)))+?\.",3)
_ArrayDisplay($arr)

qazwsxedc 发表于 2015-6-29 08:40:42

回复 4# www378660084

谢谢! 要的就是这个结果。
另外,当字符串改为
Ceramics are not typically formed from the melt. This is because most ceramics will crack extensively, i.e. form a powder, upon cooling from the liquidstate.
且不用","替换表达式中的"()"时,如何得到同样的结果
页: [1]
查看完整版本: 已解决 有多个定位字符时,如何用正则捕获