regular expression question in php preg_match

i'd like to check the following

okay:
'-'
'-1'
'-1212'
'-12.22'

not okay:
'- '
'#'
'-1/1'
'-1,2'
'-1.2.2.2'
'1,2'
'1/1'
'1.2.2'

Thanks
edyonlineAsked:
Who is Participating?
 
RoonaanConnect With a Mentor Commented:
if(preg_match('/^\-\d+(\.\d+)?$/', $value)) {
  //valid
} else {
  //invalid
}
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.