Regex
AI gave me a regex I cannot read. Should I use it?
AI gave me a regex I cannot read. Should I use it?
/^\d+$/Selected: 13800138000 → passes because the whole string is digits
Acceptance must cover rejects: inputs that should be rejected—spaces, letters, empty values—must be confirmed rejected.
Common symbol meanings: \d is one digit, + is one or more, ^ and $ match the whole string; brackets list allowed characters.
Test it with real inputs: The fastest way to judge a regex is to feed it boundary inputs: pure digits, symbols, and empty values each once.
Acceptance must cover rejects: Testing only passing cases is not acceptance; inputs that should be rejected—spaces, letters, too long—must be confirmed rejected.
Validate phone numbers with a regex and provide acceptance cases: a pure 11-digit number passes, while spaces, letters, and +86 are rejected. Afterward, run each case and confirm both pass and reject results are correct.