Can someone tell me how to validate sequence of numbers with one space and at the end there will be a optional special character say \'#\' and again followed by some 5 digit
This should do the trick
/^\d+\s\d+(?:#\d+)?$/
See it on rubular
^ beginning of string
\d+ one or more numbers
\s any whitespace character
\d+ one or more numbers
(?: begin non-capturing group
# literal '#' character
\d+ one or more numbers
) end non-capturing group
$ end of string
/^0[\d\s]{,11}(?:#\d{,5}?$/
Matches a string starting with 0, followed by a max of 11 numbers or spaces. Followed by an optional # with a max of 5 numbers after it.