Skip to content

Instantly share code, notes, and snippets.

@madr madr/javascript.js
Last active Jan 21, 2016

Embed
What would you like to do?
String replacement using regular expressions
var results = 'hi bob123';
results = results.replace(/bob\d+/, 'cooper');
<?php
$results = 'hi bob123';
$results = preg_replace('/bob\d+/', 'cooper', $results);
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
You can’t perform that action at this time.