Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bugfix] 当标题带有类似xxx.js文件名时结尾会被转大写JS #2

Merged
merged 1 commit into from
Nov 27, 2015

Conversation

overtrue
Copy link
Contributor

今天在 PHPHub 发贴的时候发现的这个问题,修复测试:

<?php

$from = "js";
$to = 'JS';
$contents = [
    '你一直在寻找的社交分享组件 overtrue/share.js',
    '你一直在寻找的社交分享组件 overtrue/share.js已经开源啦',
    '你一直在寻找的社交分享组件 overtrue/share.js 已经开源啦',
    'js 是一门脚本语言',
    'js是一门脚本语言',
    '-js是一门脚本语言 jsx ',
    ' js是一门脚本语言js',
    '大家所说的js.是一门脚本语言',
    '大家所说的js。是一门脚本语言',
    '大家所说的 js是一门脚本语言',
    '大家所说的 js 是一门脚本语言',
    '大家所说的 ejs 是一个js模板',
];

$regex = "/(?<!\.|[a-z]){$from}(?!\.|[a-z])/i";

foreach ($contents as $content) {
    echo preg_replace($regex, "\1{$to}", $content), "\n";
}

你一直在寻找的社交分享组件 overtrue/share.js
你一直在寻找的社交分享组件 overtrue/share.js已经开源啦
你一直在寻找的社交分享组件 overtrue/share.js 已经开源啦
JS 是一门脚本语言
JS是一门脚本语言
-JS是一门脚本语言 jsx
JS是一门脚本语言JS
大家所说的js.是一门脚本语言
大家所说的JS。是一门脚本语言
大家所说的 JS是一门脚本语言
大家所说的 JS 是一门脚本语言
大家所说的 ejs 是一个JS模板

nauxliu added a commit that referenced this pull request Nov 27, 2015
[Bugfix] 当标题带有类似xxx.js文件名时结尾会被转大写JS
@nauxliu nauxliu merged commit eb05777 into nauxliu:master Nov 27, 2015
@overtrue
Copy link
Contributor Author

其实这种有待讨论:

大家所说的js.是一门脚本语言"

因为有时候会有这样的情况:jquery.min.jsfoo.js.xxx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants