Use mathtools
:
\documentclass{article}
\usepackage{mathtools}
\DeclarePairedDelimiterX{\Set}[1]{\lbrace}{\rbrace}{\activatebar #1}
\newcommand{\activatebar}{%
\begingroup\lccode`~=`| \lowercase{\endgroup\let~}\activebar
\mathcode`|="8000
}
\newcommand{\activebar}{\nonscript\;\delimsize\vert\nonscript\;\mathopen{}}
\begin{document}
\[
\Set{n|n>0}
\Set[\big]{n|n>0}
\Set*{n|\begin{matrix} n>0 \\ n<42 \end{matrix}}
\]
\end{document}

Important note: don't use |
for other purposes in the argument of \Set
; it shouldn't be used anyway, preferring \lvert
and \rvert
for the absolute value. Or, of course, with macros based on mathtools
, such as
\DeclarePairedDelimiter{\abs}{\lvert}{\rvert}