Examples:-
Valid Binary number = 1010111 // true
Valid Binary point number = 101011.11 // true
Invalid Binary number = 152.35 // false
How to check?
Examples:-
Valid Binary number = 1010111 // true
Valid Binary point number = 101011.11 // true
Invalid Binary number = 152.35 // false
How to check?
You can use the regex,
[01]*\.?[01]+Demo:
Output:
Explanation of the regex at regex101:
If you also want to match a number starting with optional
0bor0B, you can use the regex,(?:0[bB])?[01]*\.?[01]+Demo:
Output:
Explanation of the regex at regex101: