Created
January 14, 2020 00:58
-
-
Save parzibyte/9927ed671bca2befcc905bdc866e5184 to your computer and use it in GitHub Desktop.
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
<?php | |
$texto = '<h3>Veamos un ejemplo</h3> | |
https://gist.github.com/parzibyte/230c66ae0499416f986cf7479f5711b1 | |
Y ahora veamos otro ejemplo: | |
https://gist.github.com/parzibyte/2d406cee65aa2707740f1eb117330825 | |
Así se termina este post :)'; | |
$patron = '/https:\/\/gist\.github\.com\/parzibyte\/([a-z0-9]+)/m'; | |
$sustitucion = '<script src="https://gist.github.com/parzibyte/$1.js"></script>'; | |
$textoConRemplazo = preg_replace($patron, $sustitucion, $texto); | |
printf("Original:\n%s\nRemplazado:\n%s", $texto, $textoConRemplazo); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment