Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
806 views
in Technique[技术] by (71.8m points)

regex - Is it possible to replace to uppercase in Visual Studio?

Is it possible to replace to upper case in Visual Studio using "Find and Replace" dialog and RegEx (?) à la: . => Upper(.)?

Say I have:

m_<b>a</b>blabla

I want:

_<b>A</b>blabla
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You can solve this by using Visual Studio temporary macros. This is a very powerful, flexible feature which I use all the time for performing repetitive code manipulations.

I'm assuming you're using the C# default key bindings here.

  1. Press CTRL+SHIFT+F to bring up the find in files dialogue.
  2. Click use "Regular expressions"
  3. Set "Find what:" to "<m_:Ll" - words that begin with m, underscore, then a lower case letter;
  4. Click "Find all" to search for all occurrences;
  5. Press CTRL+SHIFT+R to start recording temporary macro;
  6. Press F8 to find next occurrence of search expression;
  7. Press right cursor, right cursor, SHIFT + right cursor (to skip "m_" and then select the lower case letter);
  8. Press CTRL+SHIFT+U to uppercase the lower case letter;
  9. Press CTRL+SHIFT+R to stop recording temporary macro;
  10. Press CTRL+SHIFT+P to replay temporary macro, which will jump to next expression and uppercase the first letter after the "m_". You need to press CTRL+SHIFT+P as many times as there are expressions.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...