Commit 0551e82
committed
feat: Add regex-based check to validate hexadecimal number format
- Implements a simple Java program to check if a given string is a valid hexadecimal number.
- Uses the regular expression `[0-9A-F]*` to match any string composed solely of hexadecimal characters.
- `[0-9A-F]` matches any digit (0–9) or uppercase letter A–F (representing values 10–15).
- `*` quantifier allows zero or more such characters (use `+` to require at least one).
- Example used: "234AB" — a valid hexadecimal number, so the output is `true`.
📝 Notes:
- This validation assumes uppercase hex letters. To handle lowercase or mixed case, use `[0-9A-Fa-f]*`.
- Hexadecimal numbers are widely used in computing, often for memory addresses, color codes, etc.
Signed-off-by: Somesh diwan <[email protected]>1 parent a4788c1 commit 0551e82
File tree
1 file changed
+9
-8
lines changed- Section6StringClassPrinting/src
1 file changed
+9
-8
lines changedLines changed: 9 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | | - | |
| 4 | + | |
| 5 | + | |
8 | 6 | | |
9 | 7 | | |
10 | | - | |
11 | | - | |
12 | | - | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
13 | 14 | | |
14 | | - | |
| 15 | + | |
0 commit comments