I am newbee in regex so caught on a problem, I googled but unfortunately didn't got the solution so here my problem is :
I need a regex which disallow hyphen as first character(If it is the only character in the string)
Eg: - (disallow)
But if I write some digit with it then it should allow it, and also allow fraction values and also it should not allow any alphabets
Eg:
1234 (allow)
-1234 (allow)
-1234.1234 (allow)
No alphabets should be allowed in entire strings and no repetition of hyphen.
This is what I have tried so far:
((^-?[0-9]{0,4})|(^-?[0-9]{0,4}))(.[0-9]{1,4})?
It works fine for all scenario except single hyphen ie
eg: - (it is allowed using my regex but I shouldn't)
The help is truly appreciated.. :)