Created
January 12, 2017 12:56
-
-
Save PascaleBeier/4f6194f8f5fe77683d1ec15b93a55b6e to your computer and use it in GitHub Desktop.
Strip HTML Attributes from File
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env php | |
<?php | |
$openedFile = file_get_contents(__DIR__.'/'.$argv[1], 'r'); | |
$convertedString = preg_replace('/\s(color|size|class|id|style)="[^"]+"/', '', $openedFile); | |
$newFile = fopen(__DIR__.'/'.$argv[2], 'w'); | |
fwrite($newFile, $convertedString); | |
fclose($newFile); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Strip HTML Attributes from File
Usage
In a terminal:
Example