facebookarchive / codemod

Codemod is a tool/library to assist you with large-scale codebase refactors that can be partially automated but still require human oversight and occasional intervention. Codemod was developed at Facebook and released as open source.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Replace complete line (including newline) matches only every second line

david0 opened this issue · comments

Hi,
I want to remove every line that matches a specific pattern completely (including newline).
I would expect that [ \t]*require_once[^\n\r]*\r?\n? would match every line that contains requrie_once.
In fact, only every second line is removed:

Testcase:

$ cat codemodtest/A.php
<?php

require_once 'B.php';
require_once 'C.php';
require_once 'D.php';
require_once 'E.php';

class A {
}

?>


$ codemod.py -m -d codemodtest --extension php,inc '[ \t]*require_once[^\n\r]*\r?\n?' ''

$ cat codemodtest/A.php
<?php

require_once 'C.php';
require_once 'E.php';

class A {
}

?>

This sounds like a serious issue. Reopening in order to investigate.

Thank you for reporting this issue and appreciate your patience. We've notified the core team for an update on this issue. We're looking for a response within the next 30 days or the issue may be closed.