Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: Email Address Validate Check Pattern Format Match IsMatch Regular Expression RegEx System.Text.RegularExpressions.Regex dotNet
;*************************************************************************** ;** Email Checker ;** ;** Purpose: Checks that an email address matches a pattern ;** Inputs: ;** Outputs: ;** Reference: ;** REQUIRES WinBatch 2013A or newer ;** ;** Developer: Deana Falk 2014.06.13 ;*************************************************************************** If Version( )< '2013A' Pause('Notice', 'Need 2013A or Newer Version of WinBatch') Exit EndIf ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; Load assemblies into the WinBatch process. ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ObjectClrOption( 'use', 'System, Version=3.5.0.0, Culture=Neutral, PublicKeyToken=b77a5c561934e089') ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; Prompt for input ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ;link = `` ;link = `a` ; NO MATCH ;link = `@.` ; NO MATCH ;link = `a@` ; NO MATCH ;link = `a@a` ; NO MATCH ;link = `a@a.` ; NO MATCH ;link = `a@a.c` ; NO MATCH ;link = `1` ; NO MATCH ;link = `a@a.cc` ; MATCH ;link = `1@1.com` ; MATCH ;link = `a@a.com` ; MATCH ;link = `a.a@a.com` ; MATCH link = `a_a@a.com` ; MATCH ; Note must use double percent signs to indicate a single percent sign in WinBatch pattern = "(?i)\b[A-Z0-9._%%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b" ;*OR* ;pattern = "\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; Create a class implemented by a managed assembly. ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ oReg = ObjectClrNew('System.Text.RegularExpressions.Regex',pattern) If oReg.IsMatch( link ) Message('IsMatch','Match') Else Message('IsMatch','No Match') EndIf Exit
Article ID: W18524
Filename: Email Checker.txt
File Created: 2014:06:13:12:04:34
Last Updated: 2014:06:13:12:04:34