I think I created a working regular expression for what I need. Just wondering if anyone can break it or see a shorter way to write it.
The regular expression shoul
Given your examples, the following regular expression will work:
/^(\$?(?(?=\()(\())\d+(?:,\d+)?(?:\.\d+)?(?(2)\)))$/gm
(note: flags and delimiters are language dependent)
This regex sets an unnecessary backreference merely to save regex-length. You can ignore the second backreference. If this is intolerable the expression will become quite a bit longer.
Have a look here: http://regex101.com/r/fH3lV1