Skip to content

Instantly share code, notes, and snippets.

@AdamZWinter
Last active June 15, 2020 20:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AdamZWinter/2e0fecf3b450f6e7d6767cbf8b36662c to your computer and use it in GitHub Desktop.
Save AdamZWinter/2e0fecf3b450f6e7d6767cbf8b36662c to your computer and use it in GitHub Desktop.
<?php
$oldString ='version 4.4.6 ( updated 05-08-2020 )
- Improved logic to keep collapse/expand state consistent for Add/Clone/Delete/DnD actions in Layers panel.
- Updated Layers panel to allow selecting Goal and Winner for Split Testing from Layers panel.
- Improved the Visual Builder scroll performance.
- Added vmin and vmax to css allowed units in module settings.
version 4.4.5 ( updated 05-01-2020 )
- Improved logic to keep collapse/expand state consistent for Add/Clone/Delete/DnD actions in Layers panel.
- Updated Layers panel to allow selecting Goal and Winner for Split Testing from Layers panel.
- Improved the Visual Builder scroll performance.
- Added vmin and vmax to css allowed units in module settings.';
$newString = preg_replace_callback('(version [0-9].[0-9].[0-9][0-9]?)', function($matches){return 'myUnlikelyDelimiter'.$matches[0];}, $oldString);
$array = explode('myUnlikelyDelimiter', $newString);
var_dump($array);
echo '<br><br>';
$oldString ='
<!--part_name:PartName11-->
Description of the part etc...
<br>
<!--part_name:PartName22-->
Description of the next part etc...
<br>
<!--part_name:PartName33-->
Description of the last part etc...
<br>
';
function unComment ($matches){
$visible = str_replace('<!--', '', $matches[0]);
$visible = str_replace('-->', '', $visible);
return $visible;
}
$newString = preg_replace_callback('#<!--part_name:(.*?)-->#', 'unComment', $oldString);
echo '<p>'.$newString.'</p>';
echo '<br><br>';
$oldString = htmlspecialchars('<script type="text/javascript" src="/many/parents/path/file.js?version=c0af26a3543415d554bae1b8de55874b7736071d"></script>');
$newString = preg_replace_callback('#(src=&quot;)(/?)(\w*/)+([\w\d]*)(.js|.css)(\?version=)([\w\d]*)#', function($matches){return $matches[1].'/new/dir/'.$matches[4].$matches[5];}, $oldString);
echo $newString;
echo '<br><br>';
echo 'oldString: '.$oldString;
echo '<br>';
echo 'newString: '.$newString;
echo '<br><br>';
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment