Skip to content
This repository has been archived by the owner on Jun 10, 2021. It is now read-only.

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

Closed
david0 opened this issue Sep 9, 2014 · 2 comments
Closed
Labels

Comments

@david0
Copy link

david0 commented Sep 9, 2014

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 {
}

?>
@modocache
Copy link
Contributor

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

@modocache modocache reopened this Feb 20, 2015
@ghost
Copy link

ghost commented Aug 4, 2015

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.

@keyan keyan added the bug label May 17, 2016
swolchok added a commit to swolchok/codemod that referenced this issue Apr 20, 2018
Fixes facebookarchive#33. Manually tested example in that issue.
facebook-github-bot pushed a commit to facebookincubator/fastmod that referenced this issue Apr 20, 2018
Summary: facebookarchive/codemod#33 also repros in fastmod. The problem was that the amount we need to advance needs to depend on the length of the substitution: if it's zero, we need to continue scanning from the exact same offset instead of advancing.

Reviewed By: modocache

Differential Revision: D7705574

fbshipit-source-id: e58e06f79b108e3493a7c09cdd504fc07fadc05e
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants