Skip to content

Commit

Permalink
[ReplaceRegexpTask] Added flags attribute (#1867)
Browse files Browse the repository at this point in the history
* [ReplaceRegexpTask] Added `flags` attribute

* Update ReplaceRegexpTaskTest.xml

* Update ReplaceRegexpTaskTest.php
  • Loading branch information
siad007 authored Sep 20, 2024
1 parent 593141c commit bcf674d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Phing/Task/System/ReplaceRegexpTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ public function setReplace($string)
*/
public function setFlags($flags)
{
$this->regexp->setModifiers($flags);
}

/**
Expand Down
6 changes: 6 additions & 0 deletions tests/Phing/Test/Task/System/ReplaceRegexpTaskTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,10 @@ public function testFailOnError(): void
"Error reading file:"
);
}

public function testFlags(): void
{
$this->executeTarget(__FUNCTION__);
$this->assertStringEqualsFile('test.properties', 'NewProperty=12345');
}
}
6 changes: 6 additions & 0 deletions tests/etc/tasks/system/ReplaceRegexpTaskTest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,10 @@
replace="NewProperty=\1"
failonerror="true"/>
</target>
<target name="testFlags">
<replaceregexp file="test.properties"
match="oLDpROPERTY=(.*)"
replace="NewProperty=\1"
flags="i"/>
</target>
</project>

0 comments on commit bcf674d

Please sign in to comment.