Reputation: 1885
Can you please help me with a regular expression that I need for some code refactoring? I am trying to change the following
something a.executeQuery() something else
something b.executeQuery() something else
something c.executeQuery() something else
to
something someClass.executeQueryEx(a) something else
something someClass.executeQueryEx(b) something else
something someClass.executeQueryEx(c) something else
Basically trying to bring all DB calls to a central function, so that I can log them and do error handling at one place.
Upvotes: 0
Views: 43
Reputation: 11347
Assuming a,b,c are just identifiers, you can simply replace
(\w+)\.executeQuery\(\)
with
someClass.executeQueryEx(\1)
or
someClass.executeQueryEx($1)
depending on your regex engine.
If they can be arbitrary expressions, as in foo(quux).bar[25].executeQuery()
I don't think you can do that with regexes alone.
Upvotes: 2