Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Switching words in a string using replace

let re = /(w+)s(w+)/;
let str = 'John Smith';
let newstr = str.replace(re, '$2, $1');
console.log(newstr);  // Smith, John
Comment

PREVIOUS NEXT
Code Example
Javascript :: non-arrow functions are forbidden $(document).ready(function() { 
Javascript :: js array piush 
Javascript :: apiview 
Javascript :: select div with specific class not all divs jquery 
Javascript :: modal in react 
Javascript :: ** in javascript 
Javascript :: angular disabled spec.ts 
Javascript :: navigation with load page in angluar 
Javascript :: Get element inside iframe jQuery 
Javascript :: save new 
Javascript :: get computer name in javascript in adobe livecycle designer 
Javascript :: finalGrade % 5 && <38 
Javascript :: disable click extra collapse antd 
Javascript :: how to add datepicker in appended input 
Javascript :: shopify a problem repeatedly occured on url 
Javascript :: form handling in next js 
Javascript :: how to use bootstrap in reactjs 
Javascript :: Set objects Relation with Strings javascript 
Javascript :: discord.js message edit 
Javascript :: copy current filename in emacs 
Javascript :: js hit asp button onclick event 
Javascript :: js hk 
Javascript :: how to render req.session.name to ejs 
Javascript :: jQuery - The noConflict() Method 
Javascript :: Tow sums 
Javascript :: react using set Interval date time 
Javascript :: advanced javascript 
Javascript :: How to Add Main Module API to Renderer process 
Javascript :: regex to allow spaces and characters 
Javascript :: Listen to custom event in Vue js 
ADD CONTENT
Topic
Content
Source link
Name
1+1 =