playMaker

Author Topic: Check if it's an email? (solved)  (Read 1860 times)

RC

  • Full Member
  • ***
  • Posts: 148
Check if it's an email? (solved)
« on: March 19, 2015, 11:38:34 AM »
Hi,

I'm trying to see if there is a way in playmaker for me to check if there's a specific character in a string.
For example an email (@)?

I have look at unity forum, and there is a code for it. but I don't know to put it together with playmaker action.

Code: [Select]
/*
 * File: TestEmail.cs
 * Author: Mykola Dobrochynskyy
 * Version 1.0
 * Created date:  07.01.2008
 * Last upadte date:
 * Project: Common Utils
 * Description: Implements the static class, that could be used to check an E-Mail address.
 * -----------------------------------------------------------------------------
 * You are eligible to use this code for you own purpouse assuming that this
 * code and information in it is provided "AS IS" without warranty of any kind
 * expressed or implied.
 * ------------------------------------------------------------------------------
 */
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
 
namespace Dobro.Text.RegularExpressions
{
    /// <summary>
    /// Tests an E-Mail address.
    /// </summary>
    public static class TestEmail
    {
        /// <summary>
        /// Regular expression, which is used to validate an E-Mail address.
        /// </summary>
        public const string MatchEmailPattern =
            @"^(([\w-]+\.)+[\w-]+|([a-zA-Z]{1}|[\w-]{2,}))@"
            + @"((([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\.([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\."
              + @"([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\.([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])){1}|"
            + @"([a-zA-Z]+[\w-]+\.)+[a-zA-Z]{2,4})$";
 
 
        /// <summary>
        /// Checks whether the given Email-Parameter is a valid E-Mail address.
        /// </summary>
        /// <param name="email">Parameter-string that contains an E-Mail address.</param>
        /// <returns>True, wenn Parameter-string is not null and contains a valid E-Mail address;
        /// otherwise false.</returns>
        public static bool IsEmail(string email)
        {
            if (email != null) return Regex.IsMatch(email, MatchEmailPattern);
            else return false;
        }
    }
}

Thanks for helping.
« Last Edit: March 19, 2015, 11:53:22 AM by rongconcrx »

RC

  • Full Member
  • ***
  • Posts: 148
Re: Check if it's an email? (solved)
« Reply #1 on: March 19, 2015, 11:54:02 AM »
I was trying to do a string compare instead of string contain.

 :-[