Anonymously Replace string with Regex

# sion (12 days ago)

Emmmmm, pretty sorry for misleading you…

Your solution will not work if I just provide you a regex without telling you detail information, all I want is replace first and second word matched by the regex, nothing more.

# Peter Jaszkowiak (12 days ago)

All you have to do is write the regex differently:

input.replace(
  /(your )(\w+)( from )(\w+)/,
  (w, a, b, c, d) => `${a}${b.toUpperCase()}${c}${d.toLowerCase()}`
);