Email address regex pattern matching

import java.util.regex.Matcher;

import java.util.regex.Pattern;

. . .

public boolean isValidEmailAddress (String emailAddress)  {

String  expression=”^[\\w\\-]([\\.\\w])+[\\w]+@([\\w\\-]+\\.)+[A-Z]{2,4}$”;

CharSequence inputStr = emailAddress;

Pattern pattern = Pattern.compile(expression,Pattern.CASE_INSENSITIVE);

Matcher matcher = pattern.matcher(inputStr);

return matcher.matches();

}

. . .

Java - Unmarshalling - using JAXB

import javax.xml.bind.JAXBElement;

import javax.xml.bind.Unmarshaller;

import javax.xml.bind.JAXBContext;

import javax.xml.bind.JAXBException;

.  .  .

public JAXBElement<Object> unmarshal (String xmlString, Class clazz) throws JAXBException   {

StreamSource xmlSource = new StreamSource(new StringReader(xmlString));

JAXBContext jaxbContext = JAXBContext.newInstance(clazz);

Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();

return unmarshaller.unmarshal(xmlSource, clazz);

}

. . .

More Articles

Greatest Open-source softwares

URL pattern matching

Solaris processor/memory tracing commands

Why use Ubuntu Linux

Service Oriented Architecture (SOA)

Remove Control-M characters from a text-file using Vim

Resource Acquisition Is Initialization (RAII)

Sample project