Creator: How do I retain a regexp when replacing?
I would like to replace instances like
@obj.m_Member = "abc";@
to something like
However, replace does not quite do what I expect:
I search using @obj.m_Member = "\w+";@ and get the results I want.
However, when I replace with @obj.setMember("\w+");@, the \w+ is taken literally, not as the regexp result.
Anything I can do, or is this feature simply missing?
It's not missing. Without any pun you are getting what you are asking for.
@obj.m_Member = ("\w+") <- capture what's between the parenthesis@
@obj.Member(\1) <- use first captured text@
Should to what you want
Good to know. Why does it capture "what's between the parenthesis"? Parenthesis are so common in code it seems like a strange symbol to load with a special meta-meaning.
That's defined by the regexp rules: a set of parenthesis captures what's in between but that's just it's simplest usage