316428696 发表于 2010-2-4 22:19:42

向高手求教,如何正则这段代码

本帖最后由 316428696 于 2010-2-5 11:50 编辑

{"sentences":[{"trans":"黑","orig":"黑","translit":"hēi"}],"src":"en"}
{"sentences":[{"trans":"Black","orig":"黑","translit":""}],"dict":[{"pos":"名词","terms":["black","blackness","carcajou","dark","nigritude"]},{"pos":"形容词","terms":["black","dark"]},{"pos":"副词","terms":["darkly"]}],"src":"en"}
{"sentences":[{"trans":"黒","orig":"黑","translit":"kuro "}],"src":"en"}
{"sentences":[{"trans":"嘿嘿","orig":"黑","translit":"geomjeong"}],"src":"en"}取出中文

afan 发表于 2010-2-4 22:42:47

回复 1# 316428696 #include <Array.au3>
$Str = _
'{"sentences":[{"trans":"黑","orig":"黑","translit":"hēi"}],"src":"en"}' & @CRLF & _
'{"sentences":[{"trans":"Black","orig":"黑","translit":""}],"dict":[{"pos":"名词","terms":["black","blackness","carcajou","dark","nigritude"]},{"pos":"形容词","terms":["black","dark"]},{"pos":"副词","terms":["darkly"]}],"src":"en"}' & @CRLF & _
'{"sentences":[{"trans":"黒","orig":"黑","translit":"kuro "}],"src":"en"}' & @CRLF & _
'{"sentences":[{"trans":"嘿嘿","orig":"黑","translit":"geomjeong"}],"src":"en"}'
Msgbox(0, '源', $str)
$sR = StringRegExp($str, '[^\x00-\xff]+', 3)
_ArrayDisplay($sR, '中文字符')

水木子 发表于 2010-2-4 23:00:23

afan前辈果然是正则高手哦!厉害!

解决LZ问题的关键其实就是 [^\x00-\xff]+这个表达式!(匹配中文)

316428696 发表于 2010-2-5 00:16:22

afan前辈果然是正则高手哦!厉害!

解决LZ问题的关键其实就是 [^\x00-\xff]+这个表达式!(匹配中文)
水木子 发表于 2010-2-4 23:00 http://www.autoitx.com/images/common/back.gif

正则之神!出现了,不过我还是采用截取字符串的办法搞定了!

afan 发表于 2010-2-5 02:26:07

正则之神!出现了,不过我还是采用截取字符串的办法搞定了!
316428696 发表于 2010-2-5 00:16 http://www.autoitx.com/images/common/back.gif


    神没来,来的是菜鸟……
p.s, 不知道lz的用途,可能这里正则并不合适吧……

316428696 发表于 2010-2-5 11:49:37

回复 5# afan

嗯,

    很对!
页: [1]
查看完整版本: 向高手求教,如何正则这段代码