Practicing Regular Expressions Flashcards
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-Z]
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-z].*@.*\.
Write a regular expression to match valid dates in the “YYYY-MM-DD” format
202[0-9]-([0-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-9]|3[0-1])
Write a regular expression to match valid URLs with “http://” or “https://”.
http://|https://
Write a regular expression to match valid phone numbers in the format “(XXX) XXX-XXXX.”
^\(\d{3}\) \d{3}-\d{4}$
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.