validate email address without Regex

Certified Associate Developer

please tell me how to validate email address without regex means with the help of like function . 

I am writing this expression : like(ri!email,"*@gmail.com") 

but i want to validate every field like first character should not be digit and all .help me to sort out this 

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    Thanks to  there is existing code.

    community.appian.com/.../way-to-validate-email-addresses

    After reading this

    https://stackoverflow.com/questions/2049502/what-characters-are-allowed-in-an-email-address

    I think that email address validation is pretty ugly and not doable without regex. In case you want to rule out the most simple typos, then go with Mikes code. I just updated it to comply with latest changes in Appian

    a!localVariables(
      local!trimmed: trim(ri!address),
      if(
        or(
          isnull(local!trimmed),
          len(local!trimmed) > 255,
          length(split(local!trimmed, " ")) > 1,
          count(split(local!trimmed, "@")) <> 2
        ),
        false(),
        a!localVariables(
          local!localPart: split(local!trimmed,"@")[1],
          local!domainPart: split(local!trimmed,"@")[2],
          if(
            or(
              length(split(local!domainPart, ".")) < 2,
              contains(split(local!localPart, "."), ""),
              contains(split(local!domainPart, "."), ""),
              not(isnull(stripwith(lower(local!domainPart), "abcdefghijklmnopqrstuvwxyz1234567890-."))),
              not(isnull(stripwith(lower(local!localPart), "abcdefghijklmnopqrstuvwxyz1234567890-._+'&%")))
            ),
            false(),
            true()
          )
        )
      )
    )

  • +1
    Certified Lead Developer
    in reply to Stefan Helzle

    Thanks !  The above code, as its own expression rule, has helped me out in various different Appian projects since I originally wrote it, especially those where we didn't (yet) have the RegEx plug-in.  For what it's worth, since then I've swapped it out with the actual RegEx functionality as it's able to handle a little bit more.   is there a reason you can't use the RegEx plug-in?

    Here's the current code (still in an expression rule i.e. `UTIL_isValidEmailAddress()`) --

    regexmatch(
      pattern: "^[A-Z0-9\_-]+(\.{0,1}[A-Z0-9\+_-]+)*[@]{1}[A-Z0-9.-]*[A-Z0-9-]+[.]{1}[A-Z]{2,6}$",
      searchString: ri!email,
      regexFlags: "si"
    )

Reply
  • +1
    Certified Lead Developer
    in reply to Stefan Helzle

    Thanks !  The above code, as its own expression rule, has helped me out in various different Appian projects since I originally wrote it, especially those where we didn't (yet) have the RegEx plug-in.  For what it's worth, since then I've swapped it out with the actual RegEx functionality as it's able to handle a little bit more.   is there a reason you can't use the RegEx plug-in?

    Here's the current code (still in an expression rule i.e. `UTIL_isValidEmailAddress()`) --

    regexmatch(
      pattern: "^[A-Z0-9\_-]+(\.{0,1}[A-Z0-9\+_-]+)*[@]{1}[A-Z0-9.-]*[A-Z0-9-]+[.]{1}[A-Z]{2,6}$",
      searchString: ri!email,
      regexFlags: "si"
    )

Children