title: Writing or making own Regex
body: <p>Hi I am a newbie to development.I have been assigned a task of adding validations on email and password.With the help of google and stackoverflow,I have done that task.But I could not understand the real way of writing or making regex.Can anybody help me to understand the way regex should be written,following is the code I have implemented in my task .Thanks in advance!</p>
  
  <pre><code>func checkEmailValidations(testStr:String) -&gt; Bool {
          // print("validate calendar: \(testStr)")
          let emailRegEx = "[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"
  
          let emailTest = NSPredicate(format:"SELF MATCHES %@", emailRegEx)
          return emailTest.evaluate(with: testStr)
      }
  </code></pre>