Tell us what’s happening:
Describe your issue in detail here.
Dear all,
I have question regarding the following code, I’m wondering what is the difference between (\w+) and without parentheses? I can’t find the info about this.
Thanks for replying.
Your code so far
let str = "one two three";
let fixRegex = /(\w+)\s(\w+)\s(\w+)/; // Change this line
let replaceText = "$3 $2 $1"; // Change this line
let result = str.replace(fixRegex, replaceText);
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.0 Safari/605.1.15
Challenge: Use Capture Groups to Search and Replace
Link to the challenge: