Capture Groups to Search and Replace

Hello Iam trying to do this challenge, i think its right but i dont see why iam failing.

this is the FAIL: Your regex should change “one two three” to “three two one”

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);

Any TIP?

Hello!

The (w+) matches “w” exactly. The (\w+) capture group would match all characters a-z, A-Z, 0-9. :slight_smile:

1 Like

hahahaha omg i didnt see it.! thank you hahaha