🔒 Locked
Regular Expressions in Visual Studio
Advertisement
Original Post
Hi!
I just found out you can write regular expressions inside Visual Studio "Find/Replace" dialog boxes. Wow, this is really useful.. However, when I try to include the newline \n, inside the expression, it just acts as if I typed the letter n! Does anyone know how to include the newline character?
Thanks a lot!
Raj
Yeah, they''re done on a line-by-line basis (like grep) so you need to use the $ character.
codeka.com - Just click it.
If I had my way, I''d have all of you shot!
codeka.com - Just click it.
Hmm thanks a lot! That seems to work for finding the end of the line. When I try to actually insert an end-of-line though, using the Replace dialog box, it just inserts a dollar sign. Any idea of how to get around that?
Thanks a lot!
Edit: By the way, it might help to show what I'm trying to do. Basically, I'm trying to generate empty functions from the prototoypes, because this saves a lot of redundant manual editing. So, say I had this bunch of functions taken from a "Graphics" class:
Graphics();
void SetMode(int modeNumber);
void VSync();
Then, I could use regular expressions to convert this into:
Graphics::Graphics()
{
}
void Graphics::SetMode(int modeNumber)
{
}
void Graphics::VSync()
{
}
But, since I can't get newlines to work on the "Replace" dialog box, all I end up with is stuff like this:
Graphics::Graphics() {}
void Graphics::SetMode(int modeNumber) {}
void Graphics::VSync() {}
Thanks =)
Raj
[edited by - Rajansky on January 21, 2003 9:35:11 AM]
Thanks a lot!
Edit: By the way, it might help to show what I'm trying to do. Basically, I'm trying to generate empty functions from the prototoypes, because this saves a lot of redundant manual editing. So, say I had this bunch of functions taken from a "Graphics" class:
Graphics();
void SetMode(int modeNumber);
void VSync();
Then, I could use regular expressions to convert this into:
Graphics::Graphics()
{
}
void Graphics::SetMode(int modeNumber)
{
}
void Graphics::VSync()
{
}
But, since I can't get newlines to work on the "Replace" dialog box, all I end up with is stuff like this:
Graphics::Graphics() {}
void Graphics::SetMode(int modeNumber) {}
void Graphics::VSync() {}
Thanks =)
Raj
[edited by - Rajansky on January 21, 2003 9:35:11 AM]
You''re going to have to go back and edit it anyway so you could leave it as it is. You''ll need to make sure you return the correct type for non-void returns. Not hard, but a bit precarious if you ask me, you''ll have code which compiles nicely enough but does nothing.
If it''s backed up with tests and you''re following the practice of writing code which deliberately fails first time through, just to get the tests in place, then you''ll have a better chance of catching the bugs.
If it''s backed up with tests and you''re following the practice of writing code which deliberately fails first time through, just to get the tests in place, then you''ll have a better chance of catching the bugs.
I guess you could cut and paste a new line from the text editor into the replace box. I do that a bit with tabs (which you can''t type into there either).
codeka.com - Just click it.
If I had my way, I''d have all of you shot!
codeka.com - Just click it.
you guess wrongly
use perl or ruby
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement