Any Regex gurus out there? I have a position_id that is a string and can have the following formats. The number of digits can very, but is sort-of like so. all digits or digits and one dash '-'.
123456 or
123456-123
I need a regular expression that says, if position_id is not in that/those formats, throw a flag. I thought I had it with the following, but it doesn't seem to work. maybe my syntax is wrong.
if !params[:position_id] =~ /^\d+-?\d+$/
flash[:error] = "error message here"
end
any help would be appreciated.