Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find newline in Visual Studio 2013

I have a C++ source file containing many functions.

I want to find the beginning of every function quickly.

How can I form an expression for )newline{newline?

The newline symbol can be either one of the following:

  1. \n
  2. \r
  3. \n\r
  4. \r\n

Presumably, the same symbol is used all across the file, so instead of a single expression for all options combined, I need a single expression for each option.

I assume that a regular-expression can be used, but I'm not sure how.

Thanks

like image 331
barak manos Avatar asked May 20 '14 08:05

barak manos


1 Answers

Barak, before we look at individual options, for all options, this will do it:

\)[\r\n]+{[\r\n]+

The [\r\n] is a character class that allows either of \r or \n. It is quantified with a + which means we are looking for one or more of these characters.

You said you want individual options, so this can be turned to:

  1. \)\r\n{\r\n

  2. \)\r{\r

  3. \)\n{\n

  4. \)\n\r{\n\r (this sequence of newlines is quite surprising)

VS2013 regex

like image 63
zx81 Avatar answered Nov 09 '22 01:11

zx81