Regular expressions are a bit tricky, but they can be quite handy.  I found an error 
in mine; it should have read: <@REGEX 
EXPR="^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)+$"  STR="<@ARG 
email>" TYPE="E">.  I'll explain why in a sec.

I am by no means an expert, but here are some basics:
1.  The ^ tells it to look for the string only the beginning, $ matches only the end.
2.  . matches any character, + one or more occurences, * 0 or more occurences
3. Parentheses group sets of characters (and). Brackets match one of the values 
contained by them (or).
4.  Special characters need to be escaped with \
5.  Tell it which characters you want to allow.  In this case, I've allowed 
combinations of mixed case and numeric groups.

So, it's looking for a string in the format [EMAIL PROTECTED] or [EMAIL PROTECTED] which means regex 
succeeds for anything that looks like [EMAIL PROTECTED], but i also get 
[EMAIL PROTECTED], [EMAIL PROTECTED]  However shannon 
[EMAIL PROTECTED] and  al;ka'k@'KSJdflkj.com will fail because I haven't allowed for 
spaces or punctuation other than periods.

In the end, it's not much different than doing an @LOCATE except I can make sure the 
address is well-formed (though not valid) , and I can tell it which characters are 
acceptable rather than which ones are not.

<@REGEX> returns and array if it succeeds, meaning the string is correctly formed.  It 
returns text 'C' or 'M' if it fails, so I set a local variable equal to <@REGEX 
EXPR="^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)+$"  STR="<@ARG 
email>" TYPE="E"> and then check its type with <@VARINFO>; if it's text the email is 
invalid.

As to what I changed in the regular expression to validate an email, I changed the 
final * to a +.  That way, it no longer accepts shannon.henderson@reed as a valid 
address.

I hope that helps.

Shannon Henderson
Web and System Services
Reed College
Portland, OR



--- You wrote:
Shannon sent this awhile back but I am unsure how to implement it having
never used this tag before and on reading about it still being unclear.

Also I need to make sure that there are no spaces in the email in the email
and I am not sure it does that.

I am not in a hurry for an answer to this. I am expecting something that
would go in the IsMissing action.

Right now I know one sign up taf all users have a set @xxx.xxx address so I
am using <@Locate> for that and if it evaluates to 0 then I trap them.

The other I am only looking for the @ symbol. I could easily add the "."
also and the space if I could figure out who to do a locate for that so I
would end up with three missing filed inserts all different @ locates.

I can use that till I get a better understanding of this one.

Dan

on 6/4/02 12:01 PM, Shannon Henderson at
[EMAIL PROTECTED] wrote:

> If you want to use a regular expression to validate it with your taf file, you
> can use:
> <@REGEX 
> EXPR="^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*$"
> STR="<@ARG email>" TYPE="E">
> 
> The only advantage this offers is the ability to block invalid characters.
> 
> 
> Shannon Henderson
> Web and System Services
> Reed College
> Portland, OR
> 
> --- You wrote:
> Anyone have a snippet to validate email address when it is entered in a form
> make sure it is valid format.
> --- end of quote ---
> ________________________________________________________________________
> TO UNSUBSCRIBE: send a plain text/US ASCII email to [EMAIL PROTECTED]
>               with unsubscribe witango-talk in the message body
> 

-- 
Dan Stein
Digital Software Solutions
799 Evergreen Circle
Telford PA 18969
Land: 215-799-0192
Mobile: 610-256-2843
FMP, WiTango, EDI,SQL 2000
[EMAIL PROTECTED]
www.dss-db.com


________________________________________________________________________
TO UNSUBSCRIBE: send a plain text/US ASCII email to [EMAIL PROTECTED]
                with unsubscribe witango-talk in the message body
--- end of quote ---
________________________________________________________________________
TO UNSUBSCRIBE: send a plain text/US ASCII email to [EMAIL PROTECTED]
                with unsubscribe witango-talk in the message body

Reply via email to