#!/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. CentOS7防火墙

    一.CentOS7依然使用iptables的方法 CentOS7不再使用iptables,而是使用firewalld,若不想使用firewalld,可以停掉firewalld并且安装iptables- ...

  2. php 屏蔽NOTICE报错机制代码

    error_reporting=E_ALL & ~E_DEPRECATED & ~E_STRICT^E_NOTICE

  3. 2016HUAS_ACM暑假集训4A - 递推

    利用组合公式C(n,m)=C(n-1,m)+C(n-1,m-1).也就是从n个数里面选择m个数.按递增方式放在每一层循环. 杨辉三角+二项式定理,还真是挺有“意思”的一道题.说实话,非原创.见谅... ...

  4. 庞巴迪TCMS学习笔记之一(IEC 61131-3函数)

    在学习列车TCMS系统的软件逻辑图时会遇到IEC 61131-3的语言.其中通用的图形化函数总结如下.

  5. DataTable 批量插入SqlServer数据库 使用:SqlBulkCopy

    简单使用: private void UpdateTitle(DataTable dt) { ) { using (SqlBulkCopy sbc = new SqlBulkCopy(SqlHelpe ...

  6. memcache原理、简单使用、分布式实现方案

    原理:http://www.cnblogs.com/chy2055/p/5127499.html 使用教程:http://www.travisup.com/post/index/21 memcache ...

  7. 在asp.net中显示PDF的方法:

    来源:http://www.cnblogs.com/tengs2000/archive/2009/02/23/1396646.html 一.直接显示,使用的还是原页面的URL Response.Con ...

  8. Eclipse关联源码

    Eclipse关联源码 1.通常查看jdk的源码 1.悬浮在jdk的某class,右击点击Open Declaration 或F3,则调整其源码.如果没有关联源码,则会弹出: 2.点击“Attach ...

  9. 关于SAP日期操作的几个函数

    1.拆分年月---其实可以直接通过截取字符串的方法得到 CALL FUNCTION 'CACS_DATE_GET_YEAR_MONTH' EXPORTING I_DATE = SY-DATUM IMP ...

  10. LeetCode "Design Twitter"

    A mix of hashmap, list and heap. struct Tw { Tw(long long pts, int tid) { ts = pts; tweetid = tid; } ...