Regular Expressions 101

Community Patterns

Community Library Entry

1

Regular Expression
ECMAScript (JavaScript)

/
^[_.][0-9]+[a-zA-Z]*_{0,1}$
/

Description

Input Format

The first line contains a single integer, , denoting the number of usernames. Each line of the subsequent lines contains a string denoting an alien username to validate.

Constraints

Output Format

Iterate through each of the strings in order and determine whether or not each string is a valid alien username. If a username is a valid alien username, print VALID on a new line; otherwise, print INVALID.

Sample Input

3 0898989811abced _abce _09090909abcD0 Sample Output

VALID INVALID INVALID Explanation

We validate the following three usernames:

0898989811abced is valid as it satisfies the requirements specified above. Thus, we print VALID. _abce is invalid as the beginning _ is not followed by one or more digits. Thus, we print INVALID. _09090909abcD0 is invalid as the sequence of English alphabetic letters is immediately followed by a number. Thus, we print INVALID.

Submitted by anonymous - 3 years ago