visual-studiosearchvisual-studio-2022regexp-replace

In Visual Studio (ideally) I want to split and insert text into a string


Using Visual Studio 2022 Professional, I want want to replace and insert some text strings into another text string. Include the bit after the underscore as well. Some examples:

Before: CanCallGet() CanCallFetch() CanCallDelete() CanCall_Delete2() CanCallPush() CanCall_Push2()

After: CanCall_Get() CanCall_Fetch() CanCall_Delete() CanCall_Delete2() CanCall_Push() CanCall_Push2()

I have tried the Regular Expression (CanCall)[A-Z]

However, the issue is that I do not know if I can carry the matching wildcard portion (A-Z) to concatenate with the underscore and matched value.

There can be any number of matching letters for the wildcard, including A to Z.

How do I get this to work in one step?


Solution

  • Not sure if I understood correctly but doesn't this work?

    Find: (CanCall)([A-Za-z]*)(\(\))
    Replace: $1_$2$3