Simple:
^[-+]?\d+(\.\d+)?$
.NET Regular Expressions | Microsoft Docs[
^]
But depending on your requirements, it would probably be simpler to use
decimal.TryParse
to test whether the string is a valid number.
Edit: Excluding zero is slightly more complicated - a zero-width positive lookahead assertion is probably the simplest option:
^[-+]?(?=.*[1-9])\d+(\.\d+)?$
Grouping Constructs in Regular Expressions | Microsoft Docs[
^]
Again, if your intention is to validate a numeric input, then it would be better to use
decimal.TryParse
combined with any range checks on the resulting number.