regex - Creating a conditional to validate Email addresses -


I have used a preg_match based 'regex' in a PHP script which I use. Regex is ^ [\ w .-] + @ [\ w .-] + \. [AZA-Z] {2,6} $

How can I include it in a bet condition to test the email address for the original structure? My email address is in a file called 'email' (it is looped as it is necessary). Like if [cat email | '/^[\w-]+@[\w-]+\.[A-Za-z] {2,6} $ /']; Then {{/ code> or whatever, I do not know how to write it. Anyone can help you ...

Using your regular expression and assigning it to bash variable email :

  #! To test the address in / bin / bash if [[$ $ email = ~ ^ [[: alnum:] _ -] + @ [[:: alnum:] _.-] + \. [[Alpha:]] {2,6} $]] Then "good address" echo resonance "bad address" fix  <
 

Note:

  • < p> It uses [[...]] so that a simple POSIX will not open: bash or better needed.
  • = ~ operator matches a string, in this case the email address, a POSIX extended regular expression

  • The actual specificity for the email address, (see), is very complex (see this sample old) and your regex is just an approximation.

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -