55.9k views
0 votes
The first name of a person should contain only alphabets and space.

Which of the following regular expression will match the requirement?
Select one:
O [a-zA-Z ]+
O [\\s]
O [a-zA-Z
O [\\s]+​

1 Answer

5 votes

The regular expression [a-zA-Z ]+ will match a person's first name that contains only alphabets and spaces.

The regular expression that will match the requirement is [a-zA-Z ]+.

This regular expression is composed of several components:

  1. [a-zA-Z]: This matches any uppercase or lowercase alphabetic character.
  2. +: This indicates that the previous component should be repeated one or more times.
  3. : This matches a space character.

By combining these components together, the regular expression will match a string that contains only alphabets and spaces.

User JC Carrillo
by
7.7k points