php - 标点符号的字符串差异 : is preg_split the answer?

标签 php regex diff

http://piratepad.net/IY48xXzsys (由 Peter West 修改,原文来自此处:http://paulbutler.org/archives/a-simple-diff-algorithm-in-php/)

目前“I think, therefore”和“I think therefore”之间的差异会产生:

I < del >think,< /del >< ins >think< /ins > therefore

我希望它产生:

I think< del >,< /del > therefore

我认为答案是将逗号作为一个单独的实体包含在 preg_split 函数生成的数组中。我试着玩弄括号,但无法让它发挥作用。你能帮帮我吗?

最佳答案

我认为在调用 split 时在分隔符中添加一个逗号即可。

关于php - 标点符号的字符串差异 : is preg_split the answer?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6301893/

相关文章:

javascript - 是否可以在 js 中使用正则表达式来替换几个不同的字符?

java - 如何监视文件中的新内容并检索该内容

javascript - 获取两个对象数组之间差异的有效方法?

php - 查找和替换问题

java - Android fatal error : Async Task

php - 格式化数据库查询的结果

xml - RELAX NG Compact Syntax 正则表达式支持?

javascript - 使用多种类型的数据发布请求

javascript - 当有多个 http URL 时使用正则表达式获取 http URL

git - 使用 git diff,如何获取添加和修改的行号?