找回密码
 加入
搜索
楼主: wangms

[AU3基础] 【已解决】求一正则

  [复制链接]
 楼主| 发表于 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",""]]
 楼主| 发表于 2015-3-4 18:10:38 | 显示全部楼层
对于位置3的拼音部分,".*?"([^"]*?)",""] 这个可以获取
发表于 2015-3-4 18:10:41 | 显示全部楼层
回复 15# wangms


    既然都是“汉英拼”3个一组规律排列,那就根本没必要分别获取,可以一次性捕获所有引号内的内容,之后在循环里以步进值3来处理各自需要的部分。需要注意的是,里面有转义的引号\",它是不能当成当成引号来参与匹配的,最好先行处理,否则会增加正则的难度
 楼主| 发表于 2015-3-4 18:19:48 | 显示全部楼层
谢谢A大指导!转义的引号\",我知道咋样处理。步进值3  ,还请A大明示,或直接给出代码。
 楼主| 发表于 2015-3-4 18:24:16 | 显示全部楼层
另请教  \r\n  用 @CRLF 来替换,不知MsgBox里能否换行?
 楼主| 发表于 2015-3-4 18:35:36 | 显示全部楼层
根据A大指导,\[(.*?)[^\]]\] 获取如下:
[0][["郑州 - 中国的少林寺的脑袋已经渐行渐远,从媒体批评佛教机构声称寺庙的计划澳大利亚前哨会过度商业化。\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","
[1]"方丈释永信告诉记者,少林会发展为冥想,农业和设施的武术,它是著名的在东南部肖尔黑文市的“澳大利亚文化中心” 。","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”.","
[2]"我喜欢你的 - 微笑, “我喜欢你的氛围? ” , “我喜欢你的风格” 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","
[完毕]
发表于 2015-3-4 19:37:50 | 显示全部楼层
谢谢A大指导!转义的引号\",我知道咋样处理。步进值3  ,还请A大明示,或直接给出代码。
wangms 发表于 2015-3-4 18:19



    一次性捕获所有引号内的内容,之后在循环里以步进值3来处理各自需要的部分 For $i = 0 to x step 3
你上面捕获的是中括号的内容,并非引号内…
 楼主| 发表于 2015-3-4 20:23:31 | 显示全部楼层
回复 22# afan


    谢谢!现在琢磨用 For $i = 0 to x step 3 来如何获取” “里的内容并连接起来
 楼主| 发表于 2015-3-4 20:31:10 | 显示全部楼层
一次性捕获所有引号内的内容  之前,看来对 \" 不能用 ” 来进行替换,否则一次性捕获所有引号内的内容 是会乱的,那用什么来替换 \"  合适呢?
发表于 2015-3-4 20:35:51 | 显示全部楼层
我看到正则就犯晕,一点感觉也没有啊。希望楼主能尽快解决自己的问题
 楼主| 发表于 2015-3-4 21:16:19 | 显示全部楼层
本帖最后由 wangms 于 2015-3-4 21:18 编辑

回复 25# vigiles

我测试A大给出的正则,能捕获你要求的内容啊。我现在的问题现已转化为数组的各行同列相连的问题
发表于 2015-3-4 22:15:09 | 显示全部楼层
#include <Array.au3>
Local $A[6] = ['1','2', '3', '4', '5', '6']
$inc = 0
Local $B[3]
For $i = 0 To 2
        For $j = $inc To UBound($A)-1 Step 3
                $B[$i] &= $A[$j]
        Next
        $inc += 1
Next
_ArrayDisplay($B)
 楼主| 发表于 2015-3-4 23:30:11 | 显示全部楼层
回复 27# weixin067

谢谢老师给出 步进值3 的生动实例
发表于 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', ''))
 楼主| 发表于 2015-3-5 00:07:38 | 显示全部楼层
谢谢A大及其他老师的指点,结贴。
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-12-23 02:05 , Processed in 0.072606 second(s), 14 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表