Last active
January 21, 2016 11:54
-
-
Save madr/6460b808af830b7c0523 to your computer and use it in GitHub Desktop.
String replacement using regular expressions
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
var results = 'hi bob123'; | |
results = results.replace(/bob\d+/, 'cooper'); |
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 | |
$results = 'hi bob123'; | |
$results = preg_replace('/bob\d+/', 'cooper', $results); |
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
import re | |
results = 'hi bob123' | |
results = re.sub('bob\d+', 'cooper', results) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment