#!/usr/bin/php
<?
$rows = file("illwods_deal1.txt");
$goalfile = fopen("illwods_result1.txt", "w") or die("Unable to open file!");

foreach ($rows as $line)
{
$begpos = 0;
$matchpos = 0;
preg_match_all("/(\"[\x{4e00}-\x{9fa5}]\",)+/u", $line, $match);
//print_r($match);
foreach ($match as $words)
{
// print_r($words);
if(count($words) > 0 && strlen($words[0]) > 10)
{
//echo $words[0]. "\n";
preg_match_all("/[\x{4e00}-\x{9fa5}]+/u", $words[0], $strarr);
//print_r($strarr);

$matchpos = strpos($line, $words[0], $begpos);
$befstr = substr($line, $begpos, $matchpos - $begpos);
// echo "beforestr:\n" . $befstr . "\n";
fwrite($goalfile, $befstr);

$begpos = $matchpos + strlen($words[0]);

$goal = "";
foreach ($strarr[0] as $str)
{
if (strlen($goal) == 0)
{
$goal = $str;
}
else
{
$goal = $goal . "、" . $str;
}
}
if (count($strarr[0]) > 0)
{
$goal = "\"" . $goal . "\",";
}
if (strlen($goal) > 2)
{
echo "goalstr:\n" . $goal . "\n";
fwrite($goalfile, $goal);
}
}
}
$afterstr = substr($line, $begpos);
// echo "afterstr:\n" . $afterstr . "\n";
fwrite($goalfile, $afterstr);
}

fclose($goalfile);
?>

//输入文件

六四运动","六 四 运 动","六@四@运@动","六0四0运0动","六o四o运o动","六","四","运","动","六/四/运/动","六\\四\\运\\动","六|四|运|动","六’四’运’动","六,四,运,动","六四运动","六.四.运.动","六$四$运$动","六#四#运#动","六~四~运~动","六!四!运!动","六-四-运-动","六_四_运_动","【六】【四】【运】【动】",
"{六}{四}{运}{动}","(六)(四)(运)(动)","六¥四¥运¥动","[六][四][运][动]",
"GCD","G C D","G@C@D","G0C0D","GoCoD","G","C","D","G\\C\\D","G/C/D","G|C|D","G’C’D","G,C,D","GCD","G.C.D","G¥C¥D","G#C#D","G~C~D","G!C!D","G-C-D","G_C_D","【G】【C】【D】","{G}{C}{D}","(G)(C)(D)","[G][C][D]","G$C$D",
"gcd","g c d","g@c@d","g0c0d","gocod","g","c","d","g\\c\\d","g/c/d","g|c|d","g’c’d","g,c,d","gcd","g.c.d","g¥c¥d","g#c#d","g~c~d","g!c!d","g-c-d","g_c_d","【g】【c】【d】","{g}{c}{d}","(g)(c)(d)","[g][c][d]","g$c$d",
"天安门","天 安 门","天@安@门","天0安0门","天o安o门","天","安","门","天\\安\\门","天/安/门","天|安|门","天’安’门","天,安,门","天安门","天.安.门","天¥安¥门","天#安#门","天~安~门","天!安!门","天-安-门","天_安_门","【天】【安】【门】","{天}{安}{门}","(天)(安)(门)","[天][安][门]","天$安$门",

//输出文件

"六四运动","六 四 运 动","六@四@运@动","六0四0运0动","六o四o运o动","六、四、运、动","六/四/运/动","六\\四\\运\\动","六|四|运|动","六’四’运’动","六,四,运,动","六四运动","六.四.运.动","六$四$运$动","六#四#运#动","六~四~运~动","六!四!运!动","六-四-运-动","六_四_运_动","【六】【四】【运】【动】",
"{六}{四}{运}{动}","(六)(四)(运)(动)","六¥四¥运¥动","[六][四][运][动]",
"GCD","G C D","G@C@D","G0C0D","GoCoD","G","C","D","G\\C\\D","G/C/D","G|C|D","G’C’D","G,C,D","GCD","G.C.D","G¥C¥D","G#C#D","G~C~D","G!C!D","G-C-D","G_C_D","【G】【C】【D】","{G}{C}{D}","(G)(C)(D)","[G][C][D]","G$C$D",
"gcd","g c d","g@c@d","g0c0d","gocod","g","c","d","g\\c\\d","g/c/d","g|c|d","g’c’d","g,c,d","gcd","g.c.d","g¥c¥d","g#c#d","g~c~d","g!c!d","g-c-d","g_c_d","【g】【c】【d】","{g}{c}{d}","(g)(c)(d)","[g][c][d]","g$c$d",
"天安门","天 安 门","天@安@门","天0安0门","天o安o门","天、安、门","天\\安\\门","天/安/门","天|安|门","天’安’门","天,安,门","天安门","天.安.门","天¥安¥门","天#安#门","天~安~门","天!安!门","天-安-门","天_安_门","【天】【安】【门】","{天}{安}{门}","(天)(安)(门)","[天][安][门]","天$安$门",

php 正则表达式 将形如 "天," ,"安", "门" 转化为"天、安、门", (仅匹配汉字)的更多相关文章

  1. Android 正则表达式匹配汉字中文

    关于中文的正则表达式, 应该是^[\\u4E00-\\u9FFF]+$, 和论坛里常被人提起的^[\\u4E00-\\u9FA5]+$很接近需要注意的是论坛里说的^[\\u4E00-\\u9FA5]+ ...

  2. InstallShield安装包中集成第三方安装包的方案选择

    原文:InstallShield安装包中集成第三方安装包的方案选择[转]   我们在制作安装包时,有些情况下会涉及第三方安装的集成,这里将讨论如何调用安装第三方包,以及需要注意的事项. 第三方安装包的 ...

  3. Python用正则表达式匹配汉字

    Python用正则表达式匹配汉字 匹配多个汉字,不包括空格 import re res = re.match(r'[\u4E00-\u9FA5]+', '我是 汉字') print(res) # &l ...

  4. 使用Setup Factory安装包制作工具制作安装包

    在我们开发完软件后,除了极个别案例我们把整个目录复制给客户用外,我们一般都需要做成安装包,方便整个软件的部署操作,以安装包的部署操作可能简单的是复制文件,也可能包括一些注册表.数据库等额外的操作,不过 ...

  5. InstallShield安装包中集成第三方安装包的方案选择[转]

      我们在制作安装包时,有些情况下会涉及第三方安装的集成,这里将讨论如何调用安装第三方包,以及需要注意的事项. 第三方安装包的介质类型有很多,主要有:单独的一个Setup.exe,单独的一个msi包, ...

  6. 几个NAND/NOR门可以表示一个XOR门?

    这段时间就是在看测试相关的东西,无意之中发现了ISCAS85中有个名词EXOR,愣了一下反应过来应该还是异或门,毕竟叫exclusive-OR gate,其中文档中还提到了一句一个异或门可以由四个与非 ...

  7. 【WIN10】使用VS生成appx安裝包,並安裝測試

    就算沒有微軟開發者帳號,我們也是可以創建appx的. 只不過有了帳號,我們可以把這個APPX與商店中的應用關聯,並上傳,方便許多罷了. 下面就說步驟: 1.生成appx 1)菜單:項目->應用商 ...

  8. Wix Burn:如何将32位和64位的安装包制作成一个安装包

    由于Windows Installer不是平台独立的(即区分32-bit和64-bit),因此用Wix制作的安装包在编译不能像.net应用那样采用Any CPU编译,而必须制定是目标Platform是 ...

  9. Autoit3 正则表达式 匹配汉字

    关于Autoit3正则匹配汉字,在网上搜来搜去都是雷同的内容,[\u4e00-\u9fa5] 然而,Invalid all the time 直到认真钻研Help File,最终又看到了这个 http ...

随机推荐

  1. Todo List

    Contest 11.13 2016ACM/ICPC亚洲区青岛站(5/13, solved 7/13) Training 11.06 2016年中国大学生程序设计竞赛(合肥)(solved 6/10) ...

  2. 【Summary】ANSYS TRANSIENT ANALYSIS

    1.4. Damping: https://www.sharcnet.ca/Software/Ansys/15.0.7/en-us/help/ans_str/Hlp_G_STR1D.html 8.7. ...

  3. CMD:在当前文件夹下打开cmd命令

    对于电脑老鸟而言,在使用windows系统的过程中,经常需要在cmd窗口中输入一些命令进行操作.但是如果每一次都是在cmd窗口中用CD命令进行相应的文件夹目录,实在不便,尤其是在文件夹层次比较多而且带 ...

  4. 2015年我国IT行业发展趋势分析(转)

    中国信息化建设步伐正持续推进,行业和企业信息化应用水平也在不断提高,这使得it技术与应用系统已成为企业日常工作中不可或缺的基础设施.与此同时,用户关注的重心也日益转向it系统的稳定性.系统对生产效率的 ...

  5. Spell-DBC

    Spell.dbc 1  ID2  Attributes               属性3  AttributesEx             属性 4  AttributesExB         ...

  6. 在chrome 总调试cordova出现Detached from the target. Remote debugging has been terminated with reason: Connection lost. Please re-attach to the new target

    在chrome 总调试cordova出现如下错误: "Detached from the target. Remote debugging has been terminated with ...

  7. wordpress钩子和钩子函数

    ccc,看了很多博客,无法理解,还是自己来写吧. wordpress 在wordpress中有很多钩子,还有很多钩子函数,在什么地方用什么钩子,用什么钩子函数, 需要明白两个问题: 1:什么是钩子,钩 ...

  8. 欢迎你,phpWeChat 开发者

    感谢您使用 phpWeChat 来作为自己网站或者微信公共号的开发工具.phpWeChat 是一款高效.稳定的网站+微信公共号内容管理系统(CMS),也可称之为一个PHP开发框架. phpWeChat ...

  9. 判断ie版本

    (function(){ var browser=navigator.appName var b_version=navigator.appVersion var version=b_version. ...

  10. symfony2取得web目录绝对路径、相对路径、网址的函数是什么

    对于你的需求,Symfony2通过DIC提供了kernel服务,以及request(请求)的封装. 在controller里(在其他地方你可以自行注入kernel,这个服务是HttpKernel库里的 ...