Skip to content

Instantly share code, notes, and snippets.

@iuliaL
Created October 24, 2017 08:02
Show Gist options
  • Save iuliaL/cdbbbb2c92e056fbaf58948d5c1dd1c2 to your computer and use it in GitHub Desktop.
Save iuliaL/cdbbbb2c92e056fbaf58948d5c1dd1c2 to your computer and use it in GitHub Desktop.
REGEX: Using Replace with Captured Groups
let string = "Joaquin Smith";
string.replace(/^(\w+) (\w+)$/, '$2 $1')
=> "Smith Joaquin"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment