wangms 发表于 2015-3-4 18:05:38

本帖最后由 wangms 于 2015-3-4 18:13 编辑

将13楼实例这样排版一下,便于老师们看的清楚:


[[["郑州 - 中国的少林寺的脑袋已经渐行渐远,从媒体批评佛教机构声称寺庙的计划澳大利亚前哨会过度商业化。\r\n

","ZHENGZHOU -- The head of China's Shaolin Temple has distanced the Buddhist institution from media criticism claiming a planned Australian outpost of the temple will be over-commercialized.\r\n","

Zhèngzhōu - zhōngguó de shàolínsì de nǎodai yǐjīng jiàn xíng jiàn yuǎn, cóng méitǐ pīpíng fójiào jīgòu shēngchēng sìmiào de jìhuà àodàlìyǎ qiánshào huì guòdù shāngyè huà.\r\n",""],

["方丈释永信告诉记者,少林会发展为冥想,农业和设施的武术,它是著名的在东南部肖尔黑文市的“澳大利亚文化中心” 。

","Abbot Shi Yongxin told Xinhua that Shaolin will develop facilities for meditation, farming and the martial arts for which it is renowned at its \"Australian culture center\" in southeastern Shoalhaven City.","

Fāngzhàng shì yǒng xìn gàosù jìzhě, shàolín huì fāzhǎn wèi míngxiǎng, nóngyè hé shèshī de wǔshù, tā shì zhùmíng de zài dōngnán bù xiào ěr hēi wén shì de “àodàlìyǎ wénhuà zhōngxīn”.",""],

["我喜欢你的 - 微笑, “我喜欢你的氛围? ” , “我喜欢你的风格” 2009-12-31

","I like your- smile,\"I like your vibe?\",\"I like your style\" 2009-12-31","

Wǒ xǐhuān nǐ de - wéixiào, “wǒ xǐhuān nǐ de fēnwéi? ”, “Wǒ xǐhuān nǐ de fēnggé” 2009-12-31",""]]

wangms 发表于 2015-3-4 18:10:38

对于位置3的拼音部分,".*?"([^"]*?)",""] 这个可以获取

afan 发表于 2015-3-4 18:10:41

回复 15# wangms


    既然都是“汉英拼”3个一组规律排列,那就根本没必要分别获取,可以一次性捕获所有引号内的内容,之后在循环里以步进值3来处理各自需要的部分。需要注意的是,里面有转义的引号\",它是不能当成当成引号来参与匹配的,最好先行处理,否则会增加正则的难度

wangms 发表于 2015-3-4 18:19:48

谢谢A大指导!转义的引号\",我知道咋样处理。步进值3,还请A大明示,或直接给出代码。

wangms 发表于 2015-3-4 18:24:16

另请教\r\n用 @CRLF 来替换,不知MsgBox里能否换行?

wangms 发表于 2015-3-4 18:35:36

根据A大指导,\[(.*?)[^\]]\] 获取如下:
[["郑州 - 中国的少林寺的脑袋已经渐行渐远,从媒体批评佛教机构声称寺庙的计划澳大利亚前哨会过度商业化。\r\n","ZHENGZHOU -- The head of China's Shaolin Temple has distanced the Buddhist institution from media criticism claiming a planned Australian outpost of the temple will be over-commercialized.\r\n","Zhèngzhōu - zhōngguó de shàolínsì de nǎodai yǐjīng jiàn xíng jiàn yuǎn, cóng méitǐ pīpíng fójiào jīgòu shēngchēng sìmiào de jìhuà àodàlìyǎ qiánshào huì guòdù shāngyè huà.\r\n","
"方丈释永信告诉记者,少林会发展为冥想,农业和设施的武术,它是著名的在东南部肖尔黑文市的“澳大利亚文化中心” 。","Abbot Shi Yongxin told Xinhua that Shaolin will develop facilities for meditation, farming and the martial arts for which it is renowned at its \"Australian culture center\" in southeastern Shoalhaven City.","Fāngzhàng shì yǒng xìn gàosù jìzhě, shàolín huì fāzhǎn wèi míngxiǎng, nóngyè hé shèshī de wǔshù, tā shì zhùmíng de zài dōngnán bù xiào ěr hēi wén shì de “àodàlìyǎ wénhuà zhōngxīn”.","
"我喜欢你的 - 微笑, “我喜欢你的氛围? ” , “我喜欢你的风格” 2009-12-31","I like your- smile,\"I like your vibe?\",\"I like your style\" 2009-12-31","Wǒ xǐhuān nǐ de - wéixiào, “wǒ xǐhuān nǐ de fēnwéi? ”, “Wǒ xǐhuān nǐ de fēnggé” 2009-12-31","
[完毕]

afan 发表于 2015-3-4 19:37:50

谢谢A大指导!转义的引号\",我知道咋样处理。步进值3,还请A大明示,或直接给出代码。
wangms 发表于 2015-3-4 18:19 http://www.autoitx.com/images/common/back.gif


    一次性捕获所有引号内的内容,之后在循环里以步进值3来处理各自需要的部分 For $i = 0 to x step 3
你上面捕获的是中括号的内容,并非引号内…

wangms 发表于 2015-3-4 20:23:31

回复 22# afan


    谢谢!现在琢磨用 For $i = 0 to x step 3 来如何获取” “里的内容并连接起来

wangms 发表于 2015-3-4 20:31:10

一次性捕获所有引号内的内容之前,看来对 \" 不能用 ” 来进行替换,否则一次性捕获所有引号内的内容 是会乱的,那用什么来替换 \"合适呢?

vigiles 发表于 2015-3-4 20:35:51

我看到正则就犯晕,一点感觉也没有啊。希望楼主能尽快解决自己的问题

wangms 发表于 2015-3-4 21:16:19

本帖最后由 wangms 于 2015-3-4 21:18 编辑

回复 25# vigiles

我测试A大给出的正则,能捕获你要求的内容啊。我现在的问题现已转化为数组的各行同列相连的问题

weixin067 发表于 2015-3-4 22:15:09

#include <Array.au3>
Local $A = ['1','2', '3', '4', '5', '6']
$inc = 0
Local $B
For $i = 0 To 2
        For $j = $inc To UBound($A)-1 Step 3
                $B[$i] &= $A[$j]
        Next
        $inc += 1
Next
_ArrayDisplay($B)

wangms 发表于 2015-3-4 23:30:11

回复 27# weixin067

谢谢老师给出 步进值3 的生动实例

afan 发表于 2015-3-4 23:51:07

LZ已经很努力了Local $Str = ''
        $Str &= '[[["郑州 - 中国的少林寺的脑袋已经渐行渐远,从媒体批评佛教机构声称寺庙的计划澳大利亚前哨会过度商业化。\r\n","ZHENGZHOU -- The head of China' & "'s Shaolin Temple has distanced the Buddhist institution from media criticism claiming a planned Australian outpost of the temple will be over-commercialized.\r\n" & '","Zhèngzhōu - zhōngguó de shàolínsì de nǎodai yǐjīng jiàn xíng jiàn yuǎn, cóng méitǐ pīpíng fójiào jīgòu shēngchēng sìmiào de jìhuà àodàlìyǎ qiánshào huì guòdù shāngyè huà.\r\n",""],["方丈释永信告诉记者,少林会发展为冥想,农业和设施的武术,它是著名的在东南部肖尔黑文市的“澳大利亚文化中心” 。","Abbot Shi Yongxin told Xinhua that Shaolin will develop facilities for meditation, farming and the martial arts for which it is renowned at its \"Australian culture center\" in southeastern Shoalhaven City.","Fāngzhàng shì yǒng xìn gàosù jìzhě, shàolín huì fāzhǎn wèi míngxiǎng, nóngyè hé shèshī de wǔshù, tā shì zhùmíng de zài dōngnán bù xiào ěr hēi wén shì de “àodàlìyǎ wénhuà zhōngxīn”.",""],["我喜欢你的 - 微笑, “我喜欢你的氛围? ” , “我喜欢你的风格” 2009-12-31","I like your- smile,\"I like your vibe?\",\"I like your sty'
        $Str &= 'le\" 2009-12-31","Wǒ xǐhuān nǐ de - wéixiào, “wǒ xǐhuān nǐ de fēnwéi? ”, “Wǒ xǐhuān nǐ de fēnggé” 2009-12-31",""]],,"en",,[["'
;MsgBox(0, '原字符串', $Str)
$Str = StringReplace($Str, '\"', @CR)
Local $aSR = StringRegExp($Str, '"([^"]*)"', 3)
If @error Then Exit
Local $sCn, $sEn, $sPy
For $i = 0 To UBound($aSR) - 2 Step 4
        $sCn &= $aSR[$i] & @CRLF
        $aSR[$i + 1] = StringReplace($aSR[$i + 1], @CR, '"')
        $sEn &= $aSR[$i + 1] & @CRLF
        $sPy &= $aSR[$i + 2] & @CRLF
Next
MsgBox(0, '', StringReplace($sCn & @LF & $sEn & @LF & $sPy, '\r\n', ''))

wangms 发表于 2015-3-5 00:07:38

谢谢A大及其他老师的指点,结贴。
页: 1 [2] 3
查看完整版本: 【已解决】求一正则