douli6605 2016-10-29 10:30 采纳率: 100%
浏览 83

正则表达式php多行注释(Meld)

I need to diff two different version of the same app. The files are signed with a licences and that license has changed.

I don't want that files that contain the license only diff are signed as different.

I use Meld as diff software and it allows for regex.

<?php
/**
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the License ....
 *
 */

There are similar questions but none is working for me:

  1. RegEx to remove /** */ and // ** **// php comments

  2. How can I perform a diff that ignores all comments?

Regex tried:

\/\*.*?\*\/|\/\/.*?

~//?\s*\*[\s\S]*?\*\s*//?~

Actually this one looks to works but I'm not sure it is filtering too much:

\*.*

UPDATE:
This is not possible: https://mail.gnome.org/archives/meld-list/2011-December/msg00004.html

While the filter code in Meld will happily accept a regex that covers (and removes) multiple lines, this causes line mismatches between the text the diff sees and the text that we display, so all of the change blocks will be wrong.

Different approach is to remove the lines from the files before process them into meld.

  • 写回答

2条回答 默认 最新

  • dpzbh1779 2016-10-30 19:02
    关注
    \s*\/\*.*|\s*\*.*
    

    Well obviously meld doesn't accept all python regex as a text filter, no multiline nor "|" inside brackets. So this solution excludes lines beginning with a star and "/*" with optional spaces. It does not filter out all php comments precisely, but may well work for your files.

    Also have a look at that: https://mail.gnome.org/archives/meld-list/2011-December/msg00004.html

    评论

报告相同问题?

悬赏问题

  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示