Replace-3

 

Example of replace with regex expression:

 
 
 
<!DOCTYPE html> <html> <head> <title>Welcome to LearnKode - A code learning platform</title> </head> <body> <script> var regexp = /(\w+)\s(\w+)/; var str = 'Michael Voughan'; var result= str.replace(regexp , '$2, $1'); document.write(result) </script> </body> </html>
Output