Is it possible to write a macro that detects whether there is a `|` character in its arguments, and expands that to something else?

In concrete terms, I want to be able to use the following definitions simultaneously:

```
\def\P(#1){\Pr\left( #1 \right)}
\def\P(#1|#2){\Pr\left( #1 \mid #2 \right)}

```

Whenever in the text I write a probability `$\P(X)$`, the first definition should be used, whereas `$\P(X|Y)$` should use the second.

If possible, a simple TeX/LaTeX solution is preferred, since many journals put restrictions on usable packages.

I know this could be achieved using simply two different macros. The reason for this question is that the abstract of a paper often ends up printed in plain text (think the arXiv email), and I would like it to be as readable as possible.