Practicing Regular Expressions Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

Match strings that start with a capital letter followed by one or more lowercase letters. For example, it should match “Openai,” “Apple,” “Google,” but not “openAI” or “123Hello.”

A

^[A-Z]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Write a regular expression that matches an atch email addresses. A valid email address consists of one or more alphanumeric characters, followed by the “@” symbol, followed by a domain name.

A
^[a-z].*@.*\.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Write a regular expression to match valid dates in the “YYYY-MM-DD” format

A

202[0-9]-([0-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-9]|3[0-1])

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Write a regular expression to match valid URLs with “http://” or “https://”.

A
http://|https://
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Write a regular expression to match valid phone numbers in the format “(XXX) XXX-XXXX.”

A
^\(\d{3}\) \d{3}-\d{4}$
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Write a regular expression to match valid hexadecimal color codes in the format “#RRGGBB.” “RR,” “GG,” and “BB” represent two-digit hexadecimal values (00-FF) for red, green, and blue components.

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly