Search code examples
regexclion

CLion regex replace with pattern with found string


I want to replace string Sleep(*any value*) to std::this_thread::sleep_for(std::chrono::milliseconds(*found value*)).

For example, from Sleep(5000) to std::this_thread::sleep_for(std::chrono::milliseconds(5000)).

I tried to do this:
from regex: Sleep\((.*)\) to regex: std::this_thread::sleep_for\(std::chrono::milliseconds\(\1\)\)

It works in notepad++, but not in CLion. Why?
\1, \2, \3, ..., \n works only in notepad++?


Solution

  • In CLion, it is not \n, but $n to reference capture groups.

    See: https://www.jetbrains.com/help/clion/tutorial-finding-and-replacing-text-using-regular-expressions.html#capture_groups_and_backreference