Wednesday, June 21, 2006

One line Email validation using JavaScript regex

Validate if the string passed in a valid email or not

returns true or false 

var emailfilter=/^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i

returnval=emailfilter.test(<Email address to be tested >);

 

 

Posted by Babai at 09:30:51 | Permalink | No Comments »

Inserting a new line character on every nth occurrence of a space

in the below code  the 2 can be replaced  with n number and \s is for space and \n for new line charecter 

$string  =~ s/(\s)/(++$count%2==0)?”\n”:$1/ige;

Posted by Babai at 06:34:56 | Permalink | No Comments »