EDITABLE CODE:
LiveDemo: JavaScript String Object Demo
Note: $1 represents the first captured subpattern and $2 represents the second subpattern.