how do i write a regular expression to validate user input to ensure that the user input contains 1 digit, a space and any number of letters.

Recommended Answers

All 3 Replies

Although it often sounds like a regex is your solution, it's not always the case. Simply counting the required characters/digits is much simpler.

how do i that? i'm lost and have no where to start

You can use a loop, so you check each letter and keep administration of what passes are valid, invalid characters. You can use strpos to check.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.