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
Thanks to Mike Schmitt 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() ) ) ) )
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. saurabh sharma 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" )
I'm usually the one to jump on "you're using Regex WAY too quickly" but in this case, it looks like regex is much more efficient.
Unless Appian comes out with a "isValidEmail" function out of the box, regex may be your best bet.
Unknown said:Unless Appian comes out with a "isValidEmail" function out of the box
Yeah, and I've always been a little confused as to why this isn't just a usable function, because various places within Appian *certainly* do seem to do their own validation on proper email address formatting.
Edited to add (2023-02-13), the People Functions plug-in now has an email address validation function built-in, and it passes all the same test cases that I use against my RegEx version above, if this helps anyone. Once again I beg everyone not to avoid using plug-ins for arbitrary reasons, they are in many cases essential to not having to reinvent the wheel over and over again.