Recap - Email Validator
Part of the Logic & Flow section of Coddy's GDScript journey. Lesson 64 of 78.
Challenge
MediumWrite a function named clean_email_list that takes an array of email addresses, emails, and returns a new array with the valid ones, cleaned up.
- Clean every address first: remove the spaces at its start and end, and convert it to lower case.
- Then keep only the addresses that contain exactly one
@, with at least one character before it and at least one after it.
Keep the original order. Use map() and filter(), and no loop.
For example, clean_email_list(["Test@EXAMPLE.com", " invalid.email", " space@email.com "]) returns ["test@example.com", "space@email.com"].
The tests call clean_email_list() themselves. Do not call it, and do not print anything.
Try it yourself
func clean_email_list(emails: Array[String]):
# Clean the addresses with map(), then keep the valid ones with filter()
pass
All lessons in Logic & Flow
1Strings In Depth
String MethodsSearching in StringsReplace and TrimSplit and JoinRecap - Username Check4Dictionaries Part 2
Nested DictionariesArrays of DictionariesMerging DictionariesCopying DictionariesRecap - Frequency Counter2Advanced Decision Making
Match With VariablesMatch GuardsArray PatternsDictionary PatternsMembership ChecksRecap - Command Parser5Contact Book Application
Display MenuAdd Contact8Student Records Manager
Project OverviewAdd Student11Higher-Order Functions
The map MethodThe filter MethodThe reduce Methodany and allRecap - Email ValidatorRecap - Number Processor3Multi-dimensional Arrays
2D Arrays BasicsAccessing 2D Array ElementsNested Loops with 2D ArraysRecap - 2D ArraysJagged ArraysCommon 2D Array PatternsRecap - Game Board6Sets with Dictionaries
What is a Set?Dictionary as a SetAdding and RemovingUnion and IntersectionSet DifferenceRecap - Remove Duplicates9Advanced Data Aggregation
Summing ValuesFinding Minimum and MaximumCustom SortingRecap - Dictionary SorterPractice on your own: Online GDScript compiler