EDITABLE CODE:
LiveDemo: JavaScript String Object : Pattern Matching
Note: Generally, regular expressions are used to as patterns.s