Removing everything after and including the decimal, and everything non-numerical except the dash if its in is the first character. So far I have this: /[^0-9^-]|[^\.]+$/
. Notice How I block dashes from being removed with ^-
, because somehow I want to only remove the dashes that aren't the first character (not the sign). Any help? Thanks.
I just want it to remove
- Any non 0-9 characters, except the the first character if it is a dash (negative sign)
- Everything after and including the decimal point
Ex.:
10js-_67.09090FD
=> 1067
-10a.h96
=> -10
EDIT: Never mind, I was approaching this the wrong way, trying to match the characters that don't belong, and I realized I shouldn't be using a regex for this. Thanks for your answers though, I learned a bit about regex and maybe someone else with a similar problem will find this.