Knowee
Questions
Features
Study Tools

The first name of a person should contain only alphabets and space.  Which of the following regular expression will match the requirement?Select one:a.[a-zA-Z ]b.[\\s]c.[a-zA-Z  ]+d.[\\s]+

Question

The first name of a person should contain only alphabets and space.  Which of the following regular expression will match the requirement?Select one:a.[a-zA-Z ]b.[\s]c.[a-zA-Z  ]+d.[\s]+

🧐 Not the exact question you are looking for?Go ask a question

Solution

The correct answer is c. [a-zA-Z ]+

Here's why:

a. [a-zA-Z ] - This will match any single character that is a lowercase letter (a-z), an uppercase letter (A-Z), or a space. However, it will only match one character, not a sequence of characters, which is what we want for a name.

b. [\s] - This will match any single whitespace character (spaces, tabs, line breaks, etc.). It does not match alphabetic characters, so it does not meet our requirements.

c. [a-zA-Z ]+ - This will match any sequence of one or more characters that are either a lowercase letter (a-z), an uppercase letter (A-Z), or a space. This meets our requirements for a name.

d. [\s]+ - This will match any sequence of one or more whitespace characters. It does not match alphabetic characters, so it does not meet our requirements.

This problem has been solved

Similar Questions

7Which of the following regular expression patterns matches a string that contains only lowercase letters, digits, and hyphens, and starts with a letter?Review Later/^[a-z][a-z0-9-]$//[a-z][0-9a-z-]//[a-z0-9-]//^[a-z]+[a-z0-9-]$/

Which of the following strings would Python return as matches to the regular expression pattern "\w+"? Select all that apply.1 分"""#name""3""FirstName"

Which option correctly matches a string that starts with 'a' and ends with 'z', with any number of characters in between?^a*z$a*z^a.*z$a.+z

Write regular expressions for the following languages.1. the set of all alphabetic strings;2. the set of all lower case alphabetic strings ending in a b;3. the set of all strings from the alphabet a, b such that each a is immedi-ately preceded by and immediately followed by a b

Which texts below completely match the following regular expression? (Select ALL correct answers) .*on.+\d{1}.* Hint: Remember that you can use RapidMiner Studio A. con5 B. Condo #5 C. London District 7 B D. #12 Honey Lane

1/2

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.